Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, there is no way for a custom module to alter the AjaxResponse before being sent on webforms with Ajax enabled.
It would be great to have available a hook to be able to add or alter the commands that are to be sent.
Comment | File | Size | Author |
---|---|---|---|
#5 | allow_ajaxresponse_to-2911409-3.patch | 6.88 KB | jrockowitz |
|
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe solution is going to be to create a WebformViewResponse object which can be altered via an event subscriber.
@see https://www.linkedin.com/pulse/how-alter-ajax-commands-view-response-dru...
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe attached patch contains WebformSubmissionAjaxResponse object which is returned by all WebformSubmissionForm ajax responses.
Please note: Drupal is moving away from alter hooks and EventSubscribers are the recommended way to alter a request and/or a response.
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download the latest dev release to review.