Hello, I've wrote a minimal custom handler for drupal webform 8-x, it works as expected;
now I'd like to send back to the webform some custom text to display to the user; the text
depends from the webform submission fields values; I've read I could use the "[webform:handler:?]" token
but I don't understand how to put values in it from the module. I think the token will be something like:
[webform:handler:my_custom_module:completed:mytext]
but I'm unable to find a (simple) working example: I'm not a drupal programmer, the example could help me a lot
Can anyone point me to the right direction ? And where can I find documentation about classes and methods of webform module ?
Thank you
Marco
Comments
To display a message you may
To display a message you may use the code like this:
See Drupal 8 Set Message Example.
Hello wombatbuddy, thank you
Hello wombatbuddy, thank you for the answer; I think I've already tried this approach, but if I'm not wrong it just
prints a status message on top of the confirmation message; what I need is to use one (or more) results from the handler to build the
confirmation message
One way is to create a
One way is to create a "Settings" webfrom handler instead of an "Action" handler. The example:
The screenshot: https://ibb.co/w6wmpSm
But if you want to use the
But if you want to use the token, you can create a hidden element of the "value" type and populate in the webform handler. The screenshots of the example:
1. https://ibb.co/w6Xzb0D
2. https://ibb.co/bzzSpNR
3. https://ibb.co/WGsY12f
4. https://ibb.co/0VxSzpN
The code:
Hello wombatbuddy, thank you
Hello wombatbuddy, thank you very much for your very useful answers, they clarified me a lot of
things and solve my problem.
It's not important, but Just for curiosity: when are tokens like [webform:handler:handler_id:state:key] useful ?
Thank you very much
Marco
Perhaps, this can be applied
Perhaps, this can be applied in case of remote posting of webfrom submissions. For instance, this approach is used in the "webform_example_remote_post" module, which is distributed with the Webform module. You may look at the "remotePost()" method of the "RemotePostWebformHandler" class and at the "WebformExampleRemotePostController" class.
References:
1. https://git.drupalcode.org/project/webform/-/blob/6.x/src/Plugin/Webform...
2. https://git.drupalcode.org/project/webform/-/blob/6.x/modules/webform_ex...
3. https://www.drupal.org/project/webform/issues/2913491
Thank you very much again
Thank you very much again
Marco