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

Update trouble on modular form

Started by Muut Archive 10 years ago · 8 replies · 571 views
10 years ago

Form went out of order after updating through GPM.

Taken appart on a blank page, form YAML front matter is working,

but for some reason,

in modular page

form attribute name is not read anymore:
form name attribute outputs empty where it should be contact like in form YALM front matter
and
action comes like fr/_contact where it is /home in form YAML front matter.

rest of form YAML front matter is not read anymore either:
no div output for fields name, mail address, or text area.
buttons div appear but not with the form YAML front matter elements.

please note also:
that modular page is also the main landing page of site, main environnement an dit works with setup.php for subsites in folder sites: environnement sites/blog, environnement sites/docs.

Please help

10 years ago

Can you paste the form definition? Also the form modular page content.

10 years ago

Thanks.
Here 1) form definition and 2) form modular page content
1) form definition

YAML
title: ーム
menu: home
onpage_menu: true
body_classes: "modular header-image fullwidth"
anchors:
    active: false

form:
    name: name 
    action: /home
    fields:
        - name: name
          label: 
          placeholder: 名前を …
          classes: curtain-contact-form
          autofocus: off
          autocomplete: on 
          type: text
          validate:
            required: true

        - name: email
          label: ールアドレス
          placeholder: ールアドレスを …
          classes: curtain-contact-form
          type: email
          validate:
            rule: email
            required: true

        - name: message
          label: 
          placeholder: 作文を …
          classes: curtain-contact-form
          type: textarea
          validate:
            required: true

    buttons:
        - type: submit
          value: 
        - type: reset
          value: り消し

    process:
        - email:
            from: "{{ config.plugins.email.from }}"
            to:
              - "{{ config.plugins.email.from }}"
              - "{{ form.value.email }}"
            subject: "[Site Contact Form] {{ form.value.name|e }}"
            body: "{% include 'forms/data.html.twig' %}"
        - save:
            fileprefix: contact-
            dateformat: Ymd-His-u
            extension: txt
            body: "{% include 'forms/data.txt.twig' %}"
        - message: 連絡を感謝しています ♪
        - display: thankyou

content:
    items: '@self.modular'
    order:
        by: default
        dir: asc
        custom:
            - _landing-curtain
            - _blog
            - _docs
            - _about
            - _contact

2) form modular page content

YAML

title: 問い合わせ
menu: 問い合わせ
cache_enable: false

####御問い合わせ

い合わせるには、以下のフォームを御記入を…
---
10 years ago

I can see the form just fine.

Make sure you use the correct header delimiters (---) as I don't see them in your code pasted here, but might be because of formatting.

10 years ago

header delimiters are correct.

Problem is exposed in first post (please have a look at it):
after update, GRAV do not seem to be able to output form name and form action anymore.

I wonder if it is not related to:

  • subdomain structure of site
  • modular structure of page
  • both

Also, after update, GRAV was not either able to read {{ langswitcher.current }} variabme anymore

Any idea?

10 years ago

I get action and name correctly, as set on the form. Make sure your theme does not override the default partials/form.html.twig or form.html.twig, to exclude a possible source of problems.

10 years ago

Thank you. So do I. Everything works apart except on this modular page.

Folder structure of modular page is:

TXT
`01.home`
  `/_landing-curtain`
  `/_blog`
  `/_docs`
  `/_contact`
     `form.fr.md`
     `form.ja.md`
     `form.en.md`
  `/thankyou`
  `modular.fr.md`
  `modular.ja.md` (header paste above in previous post)
  `modular.en.md`

form.html.twig stand from mytheme/modular/form.html.twig [my theme works in inheritance with antimatter 1)mytheme 2)Antimatter]
and is coded:

TWIG
<div class="modular-row showcase" style="padding-bottom: 8rem;">
{% block content %}
    {{ content }}
    {% include "forms/form.html.twig" %} 
{% endblock %}
</div>

I made a test renaming form to form2 but no change.

All this was working well before update so it's probably related to it.
Also variable langswitcher.current went out of order.

plugin/form/templates/forms/default/form.html.twig is

TWIG
{% if form.message %}<div class="alert">{{ form.message }}</div>{% endif %}
{% set multipart = '' %}
{% set method = form.method|upper|default('POST') %}

{% for field in form.fields %}
    {% if (method == 'POST' and field.type == 'file') %}
        {% set multipart = ' enctype="multipart/form-data"' %}
    {% endif %}
{% endfor %}

<form name="{{ form.name }}"
      action="{{ form.action ? base_url ~ form.action : page.url }}"
      method="{{ method }}"{{ multipart }}>

{% for field in form.fields %}
    {% set value = form.value(field.name) %}
    <div>
        {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
    </div>
{% endfor %}

    <div class="buttons">
    {% for button in form.buttons %}
        <button class="{{ button.classes|default('button') }}" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
    {% endfor %}
    </div>

  {{ nonce_field('form', 'form-nonce') }}
</form>

In output, form name is blank and form action set to /fr/_contact instead of correct.

when reproducing modular form on a blank new page apart, same problem: section and title are output, but not form.
Inspecting shows that form nameis blank and form action set to /fr/modularform/_contact instead of correct.

So modular page are probably problematic

Thanks in advance

10 years ago

OK (despear must be a condition of success!)

it's was the asset and maintenance plugin!

*see bottom of this page > If the form fields do not appear if you have installed the Assets plugin disable / uninstall it. There's a known issue with it breaking modular forms will be soon fixed

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1368 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 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