1

I would like to add a confirmation form that is presented to a user on node update/delete operations triggered through the UI.

Specifically, I would like the form to present more than two choices for the user. i.e. instead of Submit/Cancel I would Option A/Option B/Option C.

Is this possible?

1 Answer 1

3

Yes. I was writing a huge response before regarding confirm_form in Drupal 7. I recommend you google and look at the examples module for confirm_form usage.

In short you probably want to:

  • use hook_form_alter to override the #submit or #action (or pre-pend to the list) the form will send to.
  • then you want to show a new form -- just like confirm_form does and do more logic in your custom confirmation form submit handler.
  • then redirect wherever using drupal_goto for instance or $form['#redirect'].

This may sound vague -- but the Form API can do all of this. You just have alot of learning to do. I have used confirm_form. I've made workflows for 8 Node forms to wizard through 8 Node add forms; and even made a "login" form fake login people from a login form completely overridden with a dropdown list of students on a Test server (to mock out users) using hook_form_alter().

Drupal can do all of this -- you just have to read the API and look at examples and experiment until you get what you want.

3
  • Thanks for pointing me in the right direction. So, I basically need to create a similar function to confirm_form but with multiple choices? Sep 10, 2013 at 23:29
  • essentially. also look at how confirm_form is linked into like the node delete operations in the default node.module file (or 1 of the node form files ... it might be node.pages.inc or something similar.
    – tenken
    Sep 11, 2013 at 6:06
  • "Drupal can do all of this -- you just have to read the API and look at examples and experiment until you get what you want." This. Yes. A hundred times yes. And Form API is one of the deeper parts of the Drupal pool in my experience :)
    – cdmo
    Sep 8, 2017 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.