Closed ghost closed 5 years ago
What does your boltforms.bolt.yml
config file look like? I'm not seeing this double name attribute myself.
The config file does contain only once the name of the form and that is 'contact'. But why does the form in the source code contains two times this name? When visiting this url, you can look at the source code: https://validator.w3.org/nu/?doc=http%3A%2F%2Fbeta.hetfestijn.nl%2F
debug:
enabled: false
address: info@willembosma.nl
csrf: true
contact:
submission:
ajax: true
notification:
enabled: true
debug: false
debug_address: name@example.com
debug_smtp: true
subject: 'Message'
from_name: name
from_email: email
replyto_email: email
replyto_name: name
to_name: 'Bericht afkomstig van'
to_email: info@test.nl
feedback:
success: 'Uw bericht is verzonden'
error: 'Er is iets misgegaan. Probeer het nog een keer'
fields:
name:
type: text
options:
required: true
label: Naam
constraints:
- NotBlank
-
Length:
min: 3
max: 128
email:
type: text
options:
required: true
label: E-mailadres
constraints:
- NotBlank
- Email
message:
type: textarea
options:
required: true
label: Bericht
submit:
type: submit
options:
label: Verzenden
attr:
class: 'button primary'
Hmm. Are you using a custom template? What does your embed twig function look like?
The only thing I've changed is the appearance of the message that the recipient receives. And in my templates I call the form with {{ boltforms('contact') }}
.
An example of the website is beta.hetfestijn.nl
It's a bug - in line https://github.com/bolt/boltforms/blob/4.2/templates/form/_form_theme.twig#L326 the form renders the form name, and all attributes .. where the name probably is repeated as a key in attr
of the form too:
{%- block form_start -%}
{%- do form.setMethodRendered() -%}
{% set method = method|upper %}
{%- if method in ["GET", "POST"] -%}
{% set form_method = method %}
{%- else -%}
{% set form_method = "POST" %}
{%- endif -%}
<form name="{{ name }}"
method="{{ form_method|lower }}"
{% if action != '' %} action="{{ action }}"{% endif %}
{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}
{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%}
{%- endblock form_start -%}
So this part repeats the name:
{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}
The quickest fix is probably the fowlling:
forms/_form_theme.twig
by removing the name="{{ name }}"
part:{%- block form_start -%}
{%- do form.setMethodRendered() -%}
{% set method = method|upper %}
{%- if method in ["GET", "POST"] -%}
{% set form_method = method %}
{%- else -%}
{% set form_method = "POST" %}
{%- endif -%}
<form
method="{{ form_method|lower }}"
{% if action != '' %} action="{{ action }}"{% endif %}
{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}
{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%}
{%- endblock form_start -%}
Please double check if this works, because I have not tested this.
I'm using the newest version of Boltforms. I noticed in the first line of code of the form, the name attribute is mentioned twice. What is the purpose of that? According to a html validator, it is an error and I want to remove it. What file do I need to edit for this?