Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

How do I parse twig variables in form fields programmatically?

Solved by yehuda View solution

Started by Anna 7 years ago · 1 replies · 814 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
2 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 Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago