0

I'm loading a webform on a Ajax modal dialog. The form submission is also set to Ajax. I want to alter the Ajax submit callback so I can have more control over the form behaviour. I'm not being able to do that. The callback being executed is always submitAjaxForm, set on the WebformAjaxFormTrait trait.

1

Try using a

hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  ....
  if (isset($form['actions']['submit'])) {
    $form['actions']['submit']['#ajax'] = [
      'callback' => '/path/to/your/controller/or/webformhandler/submitModalFormAjax',
      'event' => 'click',
    ];
}

in your *.module and then implement the callback function somewhere

public static function submitModalFormAjax(array &$form, FormStateInterface $form_state) {...}
  • 1
    I've found out hook_webform_submission_form_alter will work as well. – José Trindade Jul 5 '18 at 14:57

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.