Use same form definition for all blog items

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…

@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/

1 Like

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

Works like a charm!!!