We need to display a computed summary of submitted information on both the submission preview page and in e-mails that are sent out.

I'd expect this is a common usecase and wanted to check if i'm missing something obvious before cobbling something together (and documenting that and leading others astray!)— like figuring out if computed twig elements can be excluded from the original form, and if the same computed twig elements can be pulled into the email handler easily.

Thanks for any assistance!

(Edited body and title: clarified that this need is for the submission preview page, not the Webform 'confirmation' page)

  • OK, correction, preview page is different from confirmation page. I want the preview page— where people 'confirm' their submission before final submission, not where the site 'confirms' that they submitted. – mlncn Mar 24 at 20:14
  • Frustratingly, the message on the preview page is just a regular Drupal status message, not the more customizable webform-provided confirmation message. Likewise, the template for the preview page and the input page are both like this: ``` FILE NAME SUGGESTIONS: * webform-submission-form--webform-10152.html.twig x webform-submission-form.html.twig ``` – mlncn Mar 24 at 20:17

It's not the way i'd prefer to do it, but as far as putting customization on the preview page, there is at least an alternate template available for that:

   * webform-submission-data--preview.html.twig
   * webform-submission-data--webform-10152--preview.html.twig
   * webform-submission-data--webform-10152.html.twig
   x webform-submission-data.html.twig

Rather than use the overall template above, we decided to do most of the work in a preprocess function for a key element on the webform. This only affects the preview page, as it's about the HTML display not the form element.

function example_preprocess_webform_element_base_html__example_element__specific_instance(&$vars) {
  $rows = example_summary($vars['webform_submission']);
  $vars['table_summary'] = [
   '#type' => 'table',  
   '#rows' => $rows,

We can take the {{ table_summary }} variable we added there and include it in the custom template for that element, webform-element-base-html--example-element--specific-instance.html.twig.

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.