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.

Support

Erratic behavior of form+cache in modular page

Started by Pedro Oliveira 8 years ago · 1 replies · 467 views
8 years ago

Hi,

My forms either show 404 error after submission or , if cache cleared, it shows summary of first submission. If i submit a second form, the summary is the same as the first (emails received show the correct content). Cache is disabled in modular form and parent pages.

Decided to remove summary, so the present steps are:
1 - Submit form
2 - Received correct form in email

  • No success message in page with form*
    3 - Clear cache
    4 - Refresh page with form
  • Sucess message with fields filled with last submission *
  • Any submission after that, shows always the first one *

I have AdvancedPageCache and PreCache installed and deactivated at this moment.

Page:

<pre><code>
<span>
title: 'Dados de contacto'
cache_enable: false
form:
name: contact-form
action: /contactos
fields:

YAML
        name: name
        label: Nome
        placeholder: ''
        autofocus: 'off'
        autocomplete: 'off'
        type: text
        validate:
            required: true
    -
        name: email
        label: Email
        autofocus: 'off'
        placeholder: ''
        type: email
        validate:
            required: true
            pattern: '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,10}$'
    -
        name: message
        label: Mensagem
        type: textarea
        autofocus: 'off'
        placeholder: ''
        validate:
            required: true
    -
        name: rgpd
        label: 'Permissão RGPD'
        type: radio
        default:
            politica-de-privacidade: false
        options:
            aceito: 'Concordo com o tratamento dos meus dados, segundo descrito na política de privacidade'
        validate:
            required: true
    -
        name: permissions
        label: Notícias
        type: checkboxes
        default:
            news-eo: false
            news-epoch: false
        options:
            news-eo: 'Gostaria de receber informações adicionais sobre a actividade da Epoch Online'
            news-epoch: 'Gostaria de receber informações adicionais sobre o grupo Epoch'
        validate:
            required: false
    -
        name: how
        label: 'Como chegou até nós?'
        type: checkboxes
        default:
            Facebook: false
            Google: false
            Amigo: false
            Mkt: false
            Outro: false
        options:
            Facebook: Facebook
            Google: 'Motores de Busca'
            Amigo: 'Amigo ou Colega'
            Mkt: 'Campanha de Marketing'
            Outro: Outro
        validate:
            required: false
    -
        name: telephone
        type: honeypot
buttons:
    -
        type: submit
        value: Enviar
process:
    -
        email:
            from: '{{ config.plugins.email.from }}'
            to:
                - '{{ config.plugins.email.from }}'
                - '{{ config.plugins.email.to }}'
                - '{{ form.value.email }}'
            subject: '[Feedback] {{ form.value.name|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
    -
        save:
            fileprefix: feedback-
            dateformat: Ymd-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
    -
        message: 'thank you!'

<span>
</code></pre>

Twig:

<code>

TWIG
<section class="container {{ grid_size }}">
    <div class="columns">
        <div class="column {% if (header.extra_info) %}col-6  col-mx-auto{% else %}col-8 col-mx-auto{% endif %}  col-sm-12">
            {{ content }}
            {% if not header.formulario %} {% include "forms/form.html.twig" %} {% endif %}
            <div id="erro" style="position: absolute;"></div>
            <div id="repost"></div>
        </div>
        {% if (header.extra_info) %}
        <div class="column col-4 col-sm-12">
                {{ header.extra_info|markdown }}
        </div>
        {% endif %}
    </div>
</section>

</section>

</code>

Any help is appreciated.
Thank you.
Pedro

8 years ago

So, at this point turned the cache off (config) and forms are working as expected...
The speed wasnt much affected.

Will need more tests.
Any ideas, are more than welcome.

Cheers
Pedro

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 10 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago