I have read the docs for forms and cannot seem to get this to work. I feel like there are some gaps in the docs as I don’t feel like I have the big picture about how the forms plugins / templates are working behind the scenes after submission.
My form is a modular template as I am using it twice on the website. It is submitting and saving the text file but not displaying the thank you message.
I have tried removing the form action, moving the form into form.md, directly referencing the form-messages.html.twig in template, adding reset to the yaml, etc. Can’t seem to figure it out.
Website Page Hierarchy
- /home
- /section1
- /section2
- /contact-us
- /about
- /partners
- /contact
- /contact-us
contact.yaml
---
title: Contact
name: contact
content:
items: '@self.modular'
cache_enable: false
form:
action: /contact
method: POST
name: contact-form
fields:
-
name: name
id: name
label: Name
placeholder: Name
type: text
autofocus: true
validate:
required: true
-
name: email
id: email
label: Email
placeholder: Email
type: text
validate:
required: true
-
name: subject
id: subject
label: Subject
placeholder: Subject
type: text
validate:
required: true
-
name: message
id: message
label: Message
placeholder: 'What''s on your mind?'
type: textarea
validate:
required: true
buttons:
-
type: submit
value: Send
process:
- ip:
label: User IP Address
-
email:
from: '{{ config.plugins.email.from }}'
to: '{{ config.plugins.email.to }}'
subject: 'Message: {{ form.value.name|e }} - {{ form.value.subject|e }}'
body: '{% include ''forms/data.html.twig'' %}'
-
save:
fileprefix: contact-
dateformat: Ymd-His-u
extension: txt
body: '{% include ''forms/data.txt.twig'' %}'
-
message: 'Thank you for getting in touch!'
---
Template
{# VARIABLES #}
{% set page_title = page.title | regex_replace('/[^a-zA-Z0-9\s ]*/', '') | hyphenize | lower %}
{# TEMPLATE #}
<section id="{{ page_title }}" class="contact">
<div class="contact__form">
<div class="contact__form__content">
<h2 class="contact__title">{{ page.header.heading }}</h2>
{% block module_content %}
{{ content }}
{% include "forms/form.html.twig" %}
{% endblock %}
</div>
</div>
<div class="contact__iframe">
{{ page.header.maps.iframe | raw }}
</div>
</section>