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.

Support

Use same form definition for all blog items

Solved by pamtbaau View solution

Started by Ton Haarmans 5 years ago · 3 replies · 679 views
5 years ago

Hi,
I need to have the same form in all items of a blog. I could do that by setting the form in frontmatter for every item. Or I could use a frontmatter.yaml file in each item folder. I wonder if there is not an easier way to do this, like all blog items share the same frontmatter.yaml. Placing this in the blog folder does not work...

5 years ago Solution

@TonHaarmans, Maybe the following section in the Forms documentation might provide what you need: Displaying Forms From Twig

Using this method, you can choose a specific name of a form to display. You can even provide the name of a form defined in other pages. As long as all your form names are unique throughout your site, Grav will find and render the correct form!

When Including snippet {% include "forms/form.html.twig" with { form: forms('myform') } %} in item.html.twig , every blog item will contain the same form.

The form definition can be created in a page which is not shown. Eg. /pages/myform/form.md

👍 1
last edited 08/31/21 by pamtbaau
5 years ago

I had to read that a few times before I got it. Will try that out, thanks!!!

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 56 13 hours ago
Support · by Anna, 3 days ago
2 61 16 hours ago
Support · by Justin Young, 17 hours ago
1 32 17 hours ago
Support · by Duc , 1 week ago
2 66 5 days ago
Support · by Colin Hume, 1 week ago
2 59 5 days ago