Hi there,

how could I add a custom submit handler to a webform? This don't work..

...
function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (!empty($_COOKIE['has_js']) && !empty($_GET['modalframe']) && in_array($form_id, array('webform-client-form-109'))) {
  modalframe_child_js();
  $form['#submit'][] = 'mymodule_form_mysubmit';
 }

Comments

quicksketch’s picture

You need to add the submit handler to the actual submit button, not on the form.

$form['submit']['#submit'][] = 'mymodule_form_submit';

Note that the "submit" button may be in a different location depending on which version of Webform you're using (2.x or 3.x).

Apfel007’s picture

Thanks it works!

quicksketch’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

msypes’s picture

Issue summary: View changes

In case anyone hits this page, as I just did, 9 years later, in Drupal 7, which isn't long for the world either, it may be
$form['actions']['submit']['#submit'][] = 'mymodule_form_submit';.
In Drupal 8, it's completely different, keep searching for something more relevant. ;)