0

I have a webform in which I am using tokens to display data in the form submission confirmation and in a sent email.

Some of this data is pulled from a web service, and sometimes no data is returned by the API. This can result in the confirmation and email not being populated with data.

Form submission confirmation:

REPORT COMPLETE
Thank you for your report, which will be forwarded to: .
If you need to contact us about your report, you can do so at:
A confirmation email has been sent to: someone@example.com.

Email:

Thank you for reporting a problem at: Acme Inc.
Your report has been forwarded to .
Please do not reply to this email.

In this event, I'd like to override the confirmation and email message with a different message (that does not rely on data being available).

What is the best way to achieve this? Use hook_form_alter to test for missing values and then override the webform's #confirmation element? And how to override the email message?

Thanks.

1

The Settings handler allows you conditionally override the confirmation message and any other webform setting.

enter image description here

The Email handler support conditional logic and now also supports custom Twig template which allows you to use if/then (conditional) logic in the email message.

enter image description here

  • My confirmation message is defined at admin/structure/webform/manage/my_webform/settings/confirmation. This is not a handler, correct? Are you saying I need to define my confirmation message as a handler instead? I'm using 8.x-5.0-beta24. – 24ma13wg Jan 29 '18 at 13:34
  • The latest RC of the Webform module supports both of the above features. You would still need to define your default confirmation type & message, then you would use the 'Settings' handler to conditionally override it. BTW, I will be tagging the next RC this week. – jrockowitz Jan 29 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.