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

Dynamic form rendering // TWIG in Frontmatter

Solved by pamtbaau View solution

Started by Medi Spiegelberg 7 years ago · 3 replies · 989 views
7 years ago

Hey everybody !

So I'm trying to render a form with different dates that people from a volunteer team can fill up and check some checkboxes with different dates. Basically people with different accounts visit a page with a form and fill their free time to help...

For now it looks like this (please don't mind the graphic design since I'm still struggling with the back-end issues...):

test|421x500

And so I'm wondering if there's a good way to call a "for loop" with the dates using TWIG ?
Or maybe a nice plugin that I missed ?

Thank you for your help and don't hesitate to ask if I didn't mention important stuff in my post. Also I've searched a little bit in the forums and didn't get a straight answer to my problem.

Have a nice day !
Medi

7 years ago

EDIT: also I would like to add that I tried to put some TWIG variables in the frontmatter... but unfortunately it led to an "rendering template" error message. Also tried to add my dates into site.yaml as an array and couldn't call them in the form frontmatter.

I hope it helps !

(GRAV is the best)

7 years ago Solution

@medi, Unfortunately, I haven't found a way to add logic to the definition of a form...

The only option I see right now is to create your own plugin. A Twig template provided by the plugin could generate all required fields using a loop. And the PHP file of the plugin can in turn process the dynamically created fields.

👍 1
7 years ago

I'll see if I can get some free help with PHP !
Hahaha

Thanks a lot for your answer !

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1145 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 67 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 142 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 118 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 136 7 months ago