I have a one page website based on Grav CMS with modular pages.
One of its pages contains a contact form.
It works fine, but the problem is that the reset: true
option doesn’t work after submit. The sent data is left in the form and it could be sent once more.
I’ve tried leaving only minimum code parts with two fields, but this doesn’t make any sense.
Grav CMS 1.7.30
Form v5.1.6
pages\01.home
contains modular.lt.md
with:
content:
items: '@self.modular'
The form is placed in the contact.lt.md
:
---
title: 'Title'
menu: kontaktai
visible: true
cache_enable: false
form:
name: kontaktu-forma
template: form-messages
fields:
-
name: email
label: false
placeholder: 'e.mail'
type: email
outerclasses: form-field
classes: full-width
-
name: my-file
label: 'Add files'
type: file
multiple: true
limit: 5
filesize: 6
destination: user/data/files
accept:
- application/pdf
- application/x-pdf
- 'image/*'
-
name: telephone
label: false
placeholder: Telephone
type: tel
validate:
required: true
-
name: message
label: false
placeholder: 'Info'
type: textarea
outerclasses: form-field
classes: full-width
rows: null
buttons:
-
type: submit
value: Submit
outerclasses: form-field
classes: 'full-width btn--primary'
process:
-
email:
from:
- '{{ form.value.email|e }}'
to:
- '{{ config.plugins.email.to }}'
subject: '[Message from] {{ form.value.name|e }}'
body: '{% include ''forms/data.html.twig'' %}'
attachments:
- my-file
-
reset: true
-
message: 'Thank you message'
metadata:
'og:url': 'url'
'og:type': website
'og:title': 'title'
'og:author': author
addressTitle: 'Title'
published: true
aura:
pagetype: website
media_order: '1.jpg,2.jpg'
---
Form text
Tried with quark
theme but after submission the same code redirects to a blank page with "thank you" message
If you comment out the line template: form-messages
, the form should be correctly emptied/reset after a submit.
template: form-messages
.After submit, same page is rendered and shows correctly the "Thank you message" above the form which is emptied/reset.
Note:
form.md
not contact.md
, unless you are creating your own specific form template.visible
and published
are true
by default and don't need to be set.cache_enabled
should only be set to false
if the page should not be cached because of some dynamic data being used.