0

I built a module that submits the webform data to a soap api. The API an take a while to respond (out of my control), so what I'm looking for is a redirection hook, so I can go Submit->Force Redirection->submit to api.

Users are hitting submit more than once due to the api response time (understandably)

1 Answer 1

0

You can disable the double click on submit using the below jQuery code.

$('#formid').submit(function(){
    $(this).children('input[type=submit]').prop('disabled', true);
});

Now you can use the below code to alter submit of webform in your custom module

/**
 * Implementation of hook_form_alter().
 */
function mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
  // Add extra submit for a particular Webform node:
  if ($form_id == 'webform_client_form_44') {


    // Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
    // ours second.
   $form['#submit'][] = 'mywebform_extra_validate_44';
  }
}

/**
 * Submit handler for Webform ID #44.
 */
function mywebform_extra_submit_44(&$form, &$form_state) {
  global $user;


  // Now you can perform here api request and redirect 
}

Hope it will help you.

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.