Contact form to a modular page?

In another post I managed to use grav’s default form in the woo template (!/general:instert-a-simple-contact , tried to bump it with this subject but lets separate it ).

Now the problem I’m faced with is putting the contact into the modular home page. I have read the documentation on it:
I tried to follow the steps described but ended up with an empty section where the form should be. Here are the questions I have regarding the instructions:

  1. In your theme, add a templates/modular/form.html.twig file copying templates/forms/form.html.twig.
    a. Shouldn’t I edit first the form.html.twig to get rid of these lines?
{% extends 'partials/base.html.twig' %}
{% block content %}
{% endblock %}

b. should I copy formdata.html.twig together with forms folder from the templates folder? … inside formdata.html.twig there are references to that folder.

  1. Create a modular folder with page type
    a. Need a bit of clarification on what should I understand under modular fol der. I have a modular folder 01.home should I create a folder inside this modular folder like _contact or add a just near
    b. Can I just copy the single page that is working in single page mode into the modular folder?

  2. Add the form header to the main modular page, ?
    a. form header, that’s from the single page the from: withe name:, fields:, etc. or the whole header that is everything from except the begin/end signs ---
    b. Or for form header form: action: /is enough without any other property? (my modular page is the home page)

As for my results, if I put the near the I will get instead of my modular page the form only. If I create a _contact folder with I get the a white section that is from trying to render my form but only a little white area is all that I get instead of a form. Looking at its source I it renders my form into this:

<section id="contact" style="padding: 90px 0 72px; background: #fff;">
    <div class="alert"></div>

<form name=""

	<div class="buttons">

Thanks for any help! :slight_smile:

Going to improve the documentation on forms in modular pages this weekend.

/templates/modular/form.html.twig should be

{% block content %}
    {{ content }}
    {% include "forms/form.html.twig" %}

{% endblock %}

without the extend from base.html.twig.

  1. just create a “module” of the modular page, _contact/ for example. That md page will not contain any form definition. It’s just an indication that this is the part that should output the form.

  2. The page should contain the whole form definition, with fields etc, as if it was a “full-page” file header. With its own path as the form.action field.

Trying to follow you, still not getting it though, I still get just a blank section in the modular page. Here are the contents of some of my related files:


<section id="contact" style="padding: 90px 0 72px; background: #fff;">
{% block content %}
    {{ content }}
    {% include "forms/form.html.twig" %}
{% endblock %}    


{% extends "forms/default/form.html.twig" %}


title: xyz
menu: xyz
onpage_menu: true
body_class: index
header_class: alt
class: "custom"
   name: contact 
       - name: name
         label: Name
         placeholder: Enter your name
         autofocus: on
         autocomplete: on
         type: text
           required: true

       - name: email
         label: Email
         placeholder: Enter your email address
         type: email
           required: true

       - name: message
         label: Message
         placeholder: Enter your message
         type: textarea
           required: true

       - name: g-recaptcha-response
         label: Captcha
         type: captcha
         recatpcha_site_key: xyz
         recaptcha_not_validated: 'Captcha not valid!'
           required: true
       - type: submit
         value: Submit
       - type: reset
         value: Reset
       - email:
           subject: "[Site Contact Form] {{|e }}"
           body: "{% include 'forms/data.html.twig' %}"
       - save:
           fileprefix: contact-
           dateformat: Ymd-His-u
           extension: txt
           body: "{% include 'forms/data.txt.twig' %}"
       - message: Thank you for getting in touch!
       - display: thankyou
    action: /
    items: @self.modular    
        by: default
        dir: asc
            - _xyz
            - _contact

See my post please.

I have also the very same problem with form element.

It was working well … and it is not anymore, probably (but I don’t know) because of the update…

I have read it, but your problem is after pressing the submit button, mine is with migrating a form from single page into a modular page and until now I don’t get not even the submit button so its quite a different issue here - definitely not an issue with updates.

Can you send me your user folder privately through Gitter? Quicker way to solve this

♪ Thanks to @Flaviocopes, this issue is solved ☆

As a reference, caused by having a dot “.” in the system.yaml Updated its docs to avoid in the future

@tidivoit you have successfully stolen my thread :P, this issue is not solved.

@obeliksz as I mentioned previously, send me your user folder privately through Gitter so I can check

The OP problem was: no file in the modular page, so the form.html.twig file was never called and of course the form was not rendered.