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

Form as module on a page?

Started by Muut Archive 10 years ago · 5 replies · 376 views
10 years ago

Hi all.Is it possible to create a form as a module on a page? This form-module will be used across different pages.

10 years ago

In your page Frontmatter

TXT
show_form:true

In your Twig template:

TWIG
{% if page.header.show_form %}
{% include 'partials/form.html.twig' %}
{% endif %}

I have a custom form, I'm not sure how the Grav forms work. This may not apply to you.

10 years ago

@Ryan, it's different from what we need.

10 years ago

The only option I see now to output the same form on various pages is to have a javascript-based form from one of the services that provide form handling (wufoo, google forms..), and include it in your footer for example.

10 years ago

couldn't you just use find() on the modular route and render the content with the template?

With this I built myself a little bit of a Drupal Like Block System for content which is the same over several pages. I don't know how a form will perform within such an implementation but I think it's woth a try.

TWIG

{% set blocks_content = page.find('/foobar') %}
{% if blocks_content.template %}
   {% include blocks_content.template ~ '.html.twig' with {'header': blocks_content.header, 'page': blocks_content} %}
{% endif %}
---

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1369 9 years ago
Archive · by Muut Archive, 9 years ago
2 942 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago