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 Answer 1

2

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
  • 2
    I've found out hook_webform_submission_form_alter will work as well. Commented Jul 5, 2018 at 14:57

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.