TWIG template for webform HTML email not been picked up

Created on 22 February 2018, about 7 years ago
Updated 16 July 2023, over 1 year ago

Hi

I added a twig template for a specific form's submission to send an email with the results to a specific email address.

I had formatted the results into a set of divs etc to make the results easier to read.

Issue now is that the template been used is the one specified in the email handler.

The filename of the twig template is: webform-email-message-html--customized-email-to-admins.html.twig where "customized-email-to-admins" is the id specified in the handler details.

IS therre something else specific I am supposed to do to ensure the file is used instead of the handler Custom body? Like a HOOK with template suggestion possibly ?

Thanks
John

💬 Support request
Status

Closed: works as designed

Component

Code

Created by

🇬🇧United Kingdom johncogan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand glennnz

    I'm struggling with this too; trying to override the default 'webform submitted' email with a twig template. I've selected Twig as the email format and have added just, "This is broken..." to that field.

    If my webform name is 'custom_webform' and I've added an email handler to that webform called 'custom_handler', exactly what should my twig file be called?

    And, do I need to define this in a hook_theme()? I don't think so.

    I'm getting lots of emails telling me that it's broken....

    Thanks,

    Glenn

  • 🇳🇿New Zealand glennnz

    @jrockowitz

    Re your comment #7, how could I make those submission data items available for use in a node that wanted to display some webform data?

    Thanks.

  • 🇳🇿New Zealand glennnz

    Solved for me.

    Selected Twig template as the email handler body format, and named my twig file as webform-email-message-html--WEBFORM-ID.html.twig.

  • Status changed to Active over 1 year ago
  • 🇳🇿New Zealand glennnz

    @jrockowitz

    I have the twig template working but can't get the webform submission data to show in the email.

    I've used your code from comment #7, but can't get the data to display in the email; {{ data }} or {{data.field_name }} both show as empty in the rendered email.

    Thanks.

  • Status changed to Closed: works as designed over 1 year ago
Production build 0.71.5 2024