-2

I need to send webform submission data in an email with a specific structure:

<h2>Wizard Page 1 Title</h2>
<table>
      <tr>
        <td>Element Title</td>
        <td>Submission Value</td>
      </tr>
      ...
</table>
<h2>Wizard Page 2 Title</h2>
<table>
      <tr>
        <td>Element Title</td>
        <td>Submission Value</td>
      </tr>
      ...
</table>

I'm using the twig option in an email handler. I tried to loop through {{data}} in the handler's twig template, but it doesn't have wizard elements available. I need to do that for one specific webform Thanks! I'm editing the content of email handler

2
  • I don’t understand what this post is asking.
    – mona lisa
    Commented May 22 at 23:18
  • @monalisa I'm asking for help with using tokens in the webform submission email. I've updated the post a little bit, hope it's clearer now. As {{data}} token doesn't contain wizard page elements, is there a token that does and has a structure that I can use to present the info like it is with the default submission template, but showing elements values as a table?
    – Lena
    Commented May 23 at 18:30

1 Answer 1

0

Answering my own question, wizard pages are in the loop of elements_flattened:

   {% for key, value in elements_flattened %}
  {% if value['#type'] == 'webform_wizard_page' %}
    {% if  (loop.first == false) %}
      </table>
    {% endif %}
<h2>{{ value['#title'] }}</h2>
<table>
  {% else %}
    {% if ((webform_token('[webform_submission:values:' ~ key ~ ':clear]', webform_submission)) and (value['#type'] != 'webform_markup') and (value['#type'] != 'webform_message') ) %}
      {% if value['#type'] == 'container' or value['#type'] == 'fieldset' %}
      {% if value['#title'] %}<tr><th colspan="2">{{ value['#title'] }}</th></tr>{% endif %}
        {% else %}
      <tr>
        <td>{{ value['#title']|striptags }}</td>
        <td>{{ webform_token('[webform_submission:values:' ~ key ~ ']', webform_submission) }}</td>
      </tr>
    {% endif %}
    {% endif %}
  {% endif %}
  {% endfor %}
</table>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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