One form on multiple pages [not sending]

The structure: has 2 forms as


when you enter page in b.html.twig it has

{% include 'partials/contact_form.html.twig' with { formName : 'contact-form' } %}

the “partials/contact_form.html.twig” has

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

So the form is nicely found in (somehow) and the form is rendered as expected.

Problem: when i try to submit something, he page reloads and nothing is sent, file data.txt is not created as well.

Any help is very appreciated!

P.S. Regular pages, not modular

I use Ajax submit to do one form on multiple page, here.

Is there any way to use CMS built in functionality for that without Ajax?

I try builtin way without success, only Ajax worked for me. Here’s what I do:

{# Include the form in page template where all the page should have the same form #}
{% set formdata = page.find('/form').header.form %}
{% include "forms/form.html.twig" with {'form': formdata} %}
{% block javascript %}
// submit the form via Ajax
    $('#oneform').submit(function(e) {
            url: '{{ page.find('/form').url }}',
            type: form.attr('method'),
            dataType: 'html',
            data: form.serialize(),
            success: function(result) { 
{% endblock %}

I think i am close, and the form is working on the localhost, but on a remote i am getting this error:

[2017-04-06 14:13:08] grav.CRITICAL: Argument 1 passed to Grav\Plugin\EmailPlugin::buildMessage() must be of the type array, null given

OK, some testing, and looks like i did find i solution

Great! Can u also show how to?

The result:

  1. All the forms: are placed on one page, they are nicely found by grav
  2. Then you can include {% include “forms/form.html.twig” with { formName : ‘contact-form’ }%} inside your template and everything should be working

If something is not working, check the validity of the frontmatter, my case was wrong tabulation. Simple as that.