I'm trying to update the URL on a successful webform submission, with an inline ajax confirmation. The form works and submits fine and I already have a custom Drupal ajax command to history.push setup, but cannot figure out how to hook into the confirmation flow.

I have tried:

  • Adding a custom callback to $form['actions']['submit']['#submit'] and returning an ajax response from that callback
  • Adding a custom handler, but can't see where I could add the functionality necessary


1 Answer 1


I ended up doing this by creating an event subscriber and listening for the webform ajax response as described on this issue page: https://www.drupal.org/project/webform/issues/2911409

The keylines (amended for brevity):

// The event to listen for

// Check to see if it is a webform ajax request 
    $event->getResponse() instanceof WebformSubmissionAjaxResponse and

// Add my custom Ajax command
$event->getResponse()->addCommand(new UrlHistoryCommand)
  • 1
    Can you please post code samples of what you have implemented? I have come across a similar requirement, not sure how to check whether the form is successfully submitted in Ajax Response Event Subscriber. Please provide more info, Thanks.
    – Mathew
    May 11, 2018 at 16:52
  • 1
    Answer updated :)
    – user69676
    May 14, 2018 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.