My contact form contains a checkbox to agree to our policy before the form can be submitted. Below is email received. How do I change the grav.yes to some other text?
name: Terri
email: info@gmail.com
subject: some subject
country: Barbados
message: some message
privacy: GRAV.YES
I have tried adding the below to my existing en.yaml, but seems to take no affect. Is it not possible to replace the text?
PLUGIN_FORM:
DROPZONE_DEFAULT_MESSAGE: Drop your files here
YES: 'Yes'
NO: 'No'
@duceduc, No, AFAIK, you cannot translate the field tags in a form, only the values.
Here is a workaround…
- Add the following field to your form as demo
privacy:
type: toggle
label: Respect my privacy
highlight: yes
help: When enabled, we will respect your privacy
options:
yes: PLUGIN_ADMIN.YES
no: PLUGIN_ADMIN.NO
- Copy the Twig template used to create the email to your own theme.
NB. Use a custom theme, or child theme, not a theme from GPM.
Copy user/plugins/form/templates/forms/default/data.html.twig into folder user/themes/yourtheme/templates/forms/default/
- In your copy, replace line 69 with:
{% if field.type == 'toggle' %}
{{ (form.value(scope ~ field.name) == 'yes') ? 'PLUGIN_ADMIN.YES'|t : 'PLUGIN_ADMIN.NO'|t }}
{% else %}
{{ string(value)|e|nl2br }}
{% endif %}
- Create file en.yaml (or your preferred language) in folder /user/languages and add the following:
PLUGIN_ADMIN:
'YES': Please do
'NO': I don't bother
Your webpage will now look as follows
The email will look as follows:
Name: Yourname
Email: your@email.address
Message: Your message
Respect my privacy: Please do