1

I have a simple Entity Form and have added a custom submit handler:

$form['actions']['submit']['#submit'] = array('custom_submit','entityform_edit_form_submit');

That works very well. The problem is when I enable form preview before submission. My custom_submit function runs before preview is generated and not after it was confirmed.

How do I get it to run after form has been confirmed in preview?

$form['#submit']  = array(
    'custom_submit',
    'entityform_edit_form_submit'
);

does not work at all.

2 Answers 2

1

So this is what I found entityform module does. If preview is enabled it set $form['review']. All of my forms will have that preview set so what I did is simply:

//check if form is in preview mode and if it is then it adds my custom handler.
if(isset($form['review'])) { 
    $form['actions']['submit']['#submit'][] ='custom_submit'
}
1
  • you might want to make sure that custom_submit runs before default one. (shift array)
    – sylwester
    Commented Oct 16, 2013 at 12:13
0

You should add your submit handler to the end of the array like so:

$form['actions']['submit']['#submit'][] = 'custom_submit';
3
  • custom_submit still runs in preview with above code..
    – sylwester
    Commented Oct 15, 2013 at 15:09
  • please provide the form config for your preview button. Commented Oct 15, 2013 at 15:10
  • its a default entityform button. no changes have been made there: ` [submit] => Array ( [#type] => submit [#value] => Submit [#entityform_draft] => 0 [#submit] => Array ( [0] => entityform_edit_form_submit [1] => ramp_randomise ) [#disabled] => [#entityform_after_review] => [#executes_submit_callback] => 1 )`
    – sylwester
    Commented Oct 15, 2013 at 15:14

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.