Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

How do I parse twig variables in form fields programmatically?

Solved by yehuda View solution

Started by Anna 7 years ago · 1 replies · 1678 views
7 years ago

I'm working on a custom form processing plugin, I want to send a more complex email with a file from the file system attached. My process bit in the form looks like this:

TWIG
    process:
        -
            emailafile:
                to: '{{ form.value.email }}'
                bcc: [email protected]
                subject: 'Exposé von nest-vermittlung.de für das Objekt {{ form.value.objekt }}'
                body: 'Vielen Dank für Ihre Anfrage! Im Anhang finden Sie das angeforderte Exposé. Hier noch einmal die Daten, die Sie uns übermittelt haben: {% include ''forms/data.html.twig'' %}'
        -
            message: 'E-Mail verschickt an {{ form.value.email }}'
        -
            redirect: gesendet

This is from when I was still trying to make this work with the regular email plugin. So now I can get at these parameters in PHP alright, but how do I parse the twig bits? I've looked at the way the email plugin does it, but to be honest I don't really understand it, and simply copying code gives me an error (which I naturally don't understand either).

Can anybody explain how this works, maybe? I volunteer to put it in the docs then 🙂

👍 1
3 years ago Solution

you cant. see post
you must make the form grammatically with php

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Anna, 2 days ago
2 51 15 hours ago
Forms & Blueprints · by Anna, 3 days ago
7 81 15 hours ago
Forms & Blueprints · by Anna, 1 week ago
5 185 6 days ago
Forms & Blueprints · by TomW, 1 month ago
3 377 1 month ago
Forms & Blueprints · by Japhy, 2 months ago
2 593 2 months ago