1

On a site I'm building, a user can edit certain fields on a node that cause a chain reaction to happen (which I've implemented using hook_nodeapi's "update" op).

Since this chain reaction potentially affects a lot of other content, I'd like to inform the user of exactly what other content will be changed (which depends on the field values changed, which we don't know until the user submits the node). After the user has read this list of affected content, I'd like to give them the option to click "Yes" which will save the node and start the chain reaction, or click "No" which will take them back to the node edit form (with edits intact).

How can I make a confirmation form appear after the user clicks "Save"?

0

In brief, this is what I think you need to do in a custom module:

  1. After validation, override the submit function on the node form to submit to a new interstitial page (you'll need to implement hook_menu to create the new page)
  2. Pass the node object to the new interstitial page and define whatever logic you need in the interstitial page's callback function.
  3. Create a new form on the interstitial page that runs node_save on submit with node object that was passed to it.
0

Add javascript function as shown below and then call that function on submit using hook_form_alter. This is working for me.

/* Javascript Function */
function confirm_reg(val){   
var elem = $(this).closest('#'+val);
$.confirm({
    'title'     : 'Confirmation',
    'message'   : 'Are you sure to submit the details ?',
    'buttons'   : {
        'Yes'   : {
            'class' : 'blue',
            'action': function(){    
                $("#your_form_id").submit();
                return true;
            }
        },
        'No'    : {
            'class' : 'gray',
            'action': function(){
                return false;
            }   // Nothing to do in this case. You can as well omit the action property.
        }
    }
});
}
 /* hook_form_alter */
 function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
 global $user;   
 if ($form_id == "your_form_id") {       
    $form['submit']['#attributes'] = array('onclick' => 'if(!confirm_reg(this.id)){return false;}');
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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