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:
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: [email protected].
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?