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

Form disapears after a while

form

Started by Thomas 8 years ago · 9 replies · 1157 views
8 years ago

again some issue with the forms 😦

  1. I use forms a lot ...
  2. I have a form in the footer on every page.
  3. All pages are modular page.

Everything visible and defined in the frontmatter disapperas after a while (approx. 2h).
Only the form-html with the hidden input-fields for __unique_form_id__ and form-nonce etc. gets rendered.

The footer is a template-partial and loads the form with this include
{% include "forms/form.html.twig" with { 'form': forms('footer-form') } %}

I guess it has something to do with caching.
So what are the ideal values for the different caching layers when I want to use forms?

last edited 04/07/18 by Thomas
8 years ago

from my current system.yaml:

YAML
pages:
  expires: 3600
[...]
cache:
  enabled: true
  check:
    method: file
  driver: auto
  prefix: g
  cli_compatibility: false
  lifetime: 3600
  gzip: true
  allow_webserver_gzip: true
twig:
  cache: false
  debug: false
  auto_reload: true
  autoescape: false
  undefined_functions: true
  undefined_filters: true
  umask_fix: false

from my footer-form.md-frontmatter

TXT
cache_enable: false
8 years ago

this is how the renderd "form" looks like:

HTML
<form name="" action="" method="POST" class=" ">

  <input type="hidden" name="__form-name__" value="">

    <div class="buttons">

    </div>

  <input type="hidden" name="__unique_form_id__" value="vkU0XcdsmPtQfp2x6RHZ">  <input type="hidden" name="form-nonce" value="f4b5012d54a59c62de78d4d4486bab85">
</form>
8 years ago

and this is how the forms gets renderd directly after clearing the cache:

HTML
<form name="footer-form" action="" method="POST" id="footer-form" class=" row 50%">

    <div class="form-field 3u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Anrede

                        <span class="required">*</span>
                                        </label>
                </div>
                        <div class="form-data " data-grav-selectize="[]" data-grav-field="select" data-grav-disabled="true" data-grav-default="null">
                                        <div class="form-select-wrapper  ">
        <select name="data[Anrede]" class=" " required="required">
            <option value="" disabled="" selected="">Anrede</option>
                                                            <option value="Frau">Frau</option>
                                                            <option value="Herr">Herr</option>
                    </select>
    </div>

            </div>
            </div>

    <div class="form-field 9u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Name

                        <span class="required">*</span>
                                        </label>
                </div>
                        <div class="form-data " data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[Name]" value="" type="text" class=" " placeholder="Vor-/Nachname" required="required">
                                                                                    </div>

            </div>
            </div>

    <div class="form-field 12u  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        eMail

                        <span class="required">*</span>
                                        </label>
                </div>
                        <div class="form-data " data-grav-field="email" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[eMail]" value="" type="email" class=" " placeholder="eMail" required="required">
                                                                                </div>

            </div>
            </div>

    <div class="form-field 6u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Anreise

                        <span class="required">*</span>
                                        </label>
                </div>
                        <div class="form-data " data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[Ankunft]" value="" type="text" class=" " placeholder="Anreise (TT.MM.JJJJ)" required="required" pattern="^([1-9]|0[1-9]|[12][0-9]|3[01])\.([1-9]|0[1-9]|1[012])\.(20)?\d{2}$" title="kein gültiges Datum oder Format (TT.MM.JJJJ)">
                                                                                    </div>

            </div>
            </div>

    <div class="form-field 6u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Abreise

                        <span class="required">*</span>
                                        </label>
                </div>
                        <div class="form-data " data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[Abreise]" value="" type="text" class=" " placeholder="Abreise (TT.MM.JJJJ)" required="required" pattern="^([1-9]|0[1-9]|[12][0-9]|3[01])\.([1-9]|0[1-9]|1[012])\.(20)?\d{2}$" title="kein gültiges Datum oder Format (TT.MM.JJJJ)">
                                                                                    </div>

            </div>
            </div>

    <div class="form-field 6u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Anzahl Erwachsene

                                        </label>
                </div>
                        <div class="form-data " data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[Anzahl Erwachsene]" value="" type="text" class=" " placeholder="Anzahl Erwachsene">
                                                                                    </div>

            </div>
            </div>

    <div class="form-field 6u 12u(mobilep)  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Anzahl Kinder

                                        </label>
                </div>
                        <div class="form-data " data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper  ">
                                                        <input name="data[Anzahl Kinder]" value="" type="text" class=" " placeholder="Anzahl Kinder">
                                                                                    </div>

            </div>
            </div>

<input data-grav-field="hidden" data-grav-disabled="false" type="hidden" class="input" name="data[url]" value="/">

    <div class="form-field 12u  ">
                                    <div class="form-label ">
                    <label class="inline">
                                                                                                        Nachricht

                                        </label>
                </div>
                        <div class="form-data " data-grav-field="textarea" data-grav-disabled="true" data-grav-default="null">
                                        <div class="form-textarea-wrapper  ">
        <textarea name="data[Nachricht]" class=" " placeholder="Nachricht" rows="4"></textarea>
    </div>

            </div>
            </div>
              <input type="text" style="display:none;" name="data[spam]" value="">  
  <input type="hidden" name="__form-name__" value="footer-form">

    <div class="buttons">

                            <button class="button " type="submit">
                Anfrage abschicken
          </button>
                                            <button class="button alt" type="reset">
                zurück setzen
          </button>

    </div>

  <input type="hidden" name="__unique_form_id__" value="SkxM7snK2YwDt8PTez4F">  <input type="hidden" name="form-nonce" value="f4b5012d54a59c62de78d4d4486bab85">
</form>
6 years ago

Please add (or modify) these frontmatter settings in the contact form page:

YAML
never_cache_twig: true
cache_enable: false

Does the problem still persist?

6 years ago

If it helps: I just tested the page/form using Incognito mode, and it seems to work good.

6 years ago

There is another proposal from @Andrass here:
/forum/general/contact-form-disappearing-randomly-t2920?u=hschneider

Let's move the conversation to the other thread. Cross-postings are rather confusing ...

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1136 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 134 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