Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Use same form definition for all blog items

Solved by pamtbaau View solution

Started by Ton Haarmans 5 years ago · 3 replies · 909 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 webmasterodp, 1 week ago
4 176 1 week ago
Support · by nwhitfield, 1 week ago
2 153 1 week ago
Support · by stell, 3 weeks ago
5 387 2 weeks ago
Support · by gravinator, 1 month ago
5 580 2 weeks ago
Support · by Gravver, 3 weeks ago
6 364 3 weeks ago