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.
Problem/Motivation
We need to modify the response for success and for errors on webform_rest submit
Proposed resolution
Implements hook_alter for these cases
Comment | File | Size | Author |
---|---|---|---|
#10 | 3137074-for-4.0.1.patch | 3.83 KB | viniciusrp |
#2 | 3137074.patch | 2.15 KB | renatog |
Issue fork webform_rest-3137074
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
renatogFollow the patch in attachment. Please review.
Thanks
Comment #3
renatogWith this approach, all projects can modify responses with alter. Example:
Comment #4
andre.bonon CreditAttribution: andre.bonon at CI&T commentedWorks for me ! =)
It is really helpful for cases that you need to return a custom response.
Thanks!
Comment #5
andre.bonon CreditAttribution: andre.bonon at CI&T commentedComment #6
imclean CreditAttribution: imclean at Digital Ink commentedYou can use dependency injection for the module handler service. There shouldn't be any calls to
\Drupal::
outside procedural code.Comment #7
renatogIt really makes sense.
So the final result will be
Ok, we'll do that.
Thanks
Comment #8
imclean CreditAttribution: imclean at Digital Ink commentedThe service is module_handler so
moduleHandler
might be a better variable name.Comment #9
anabpvI'll work on this.
Comment #10
viniciusrp CreditAttribution: viniciusrp commentedI made a refactor at this patch to 4.0.1 version.
I'll work to create a version with Events to replace the hook_alter.
Comment #11
renatog#10 really looks great to me. +1 to RTBC
Comment #12
anabpvComment #13
fadonascimento CreditAttribution: fadonascimento at CI&T for CI&T commented+1 in favor to use Events instead of hook_alter see details:
https://www.drupal.org/project/webform_rest/issues/3261131
Comment #14
nsalves CreditAttribution: nsalves at NTT DATA commentedHey guys, we decided to go with the event approach described in (#3261131) since its more flexible and avoids the use of "drupalisms" so I'll be closing this ticket but thanks for the effort
Comment #15
nsalves CreditAttribution: nsalves at NTT DATA commented