Pantheon Community

Assistance with Twig template

Right now I’m working on a contact form, and I’m almost finished with it, I’m just working out a few small issues and trying to finetune it. I’m using the Twig template to output all the fields that have text in them using this PHP(?) script:

{{ webform_token(’[webform_submission:values]’, webform_submission) }}

It’s pretty basic and gets the job done, but I’d like to know how I can use this script to cherry pick certain pieces of data and exclude redundant data. For example, when the contact form is filled out, some of the information presented include a name and email, which we don’t need because it’s included automatically when the contact form sends the info in an email. So when I try to cherry pick information, I’ll try these scripts:

{{ webform_token(’[webform_submission:values:element_image_attachment]’, webform_submission) }}
{{ webform_token(’[webform_submission:values:element_message]’, webform_submission) }}

I put in the keys for the data fields I want to see, but these commands must not be right because it doesn’t bring up the data. Would anyone be able to tell me if I have the format wrong? Thanks in advance.

1 Like

I haven’t done this specifically, but have worked with Webforms in a few ways. But I did find this:

The latest Webform UI seems to use a lot more references to TWIG, so perhaps look in the UI for how they reference submission values? Good luck!

1 Like