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

Displaying a form within a modal

Started by Milind Joshi 9 years ago · 2 replies · 1183 views
9 years ago

Hi,
I am totally new to grav.
I'm trying to display a form within a modal, so, something like this:

YAML
---
title: Portfolio
menu: portfolio
portfolios:
    - title: Home
<Insert form1 here>
      subtitle:
      layout: default
      modalid: 1
      date: 2014-07-18
      img: blah.jpg
      thumbnail: blah.jpg
      alt: image-alt
      projectdate: April 2014
      client: Start Bootstrap
      category: test text
      description: test text
    - title: Auto
<insert form2 here>
      subtitle:
      layout: default
      modalid: 2
      date: 2014-07-17
      img: test2.jpg
      thumbnail: test2.jpg
      alt: image-alt
      projectdate: April 2014
      client: Start Bootstrap
      category: test2
      description: testtext 2

How could I do this?

last edited 07/10/17 by flavio
9 years ago

You wrote modal, I assume you mean "modal" and not "modular", right?

In any way, the concept is the same. Multiple forms can be defined in the page, and then you include the form in your Twig, specifying which form it should display.

In your case, you can define in that page header:

YAML
forms:
    form1:
        fields:
            ...
        buttons:
            ...
        process:
            ...

    form2:
        fields:
            ...
        buttons:
            ...
        process:
            ...

Then add formname in each portfolio item, and enter for example form1. In the portfolio Twig, if portfolio_item is the variable you iterate on, add

{% include "forms/form.html.twig" with { form: forms(portfolio_item.formname) } %}

That should work!

9 years ago

Thank you very much Flavio, I will try this. I think grav is brilliant in its architecture and elegance. I look forward to using, learning, and increasing the adoption of grav!

👍 1

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1138 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago