From 02ee7063187d1eef3a12c7987b0e6de7f77d9059 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Wed, 13 Jan 2021 18:56:01 +0100 Subject: [PATCH] Added safe_email filter for email field Note: This requires grav 1.7.0-rc.18, as safe_email got fixed there: https://github.com/getgrav/grav/commit/068de42e833af8baeb96fe31c170964fa2df0d4b --- templates/forms/fields/email/email.html.twig | 36 ++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/templates/forms/fields/email/email.html.twig b/templates/forms/fields/email/email.html.twig index 7832460e..7f90951e 100644 --- a/templates/forms/fields/email/email.html.twig +++ b/templates/forms/fields/email/email.html.twig @@ -1,10 +1,32 @@ {% extends "forms/field.html.twig" %} -{% block input_attributes %} - type="email" - {% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %} - {% if field.size %}size="{{ field.size }}"{% endif %} - {% if field.minlength is defined or field.validate.min is defined %}minlength="{{ field.minlength | default(field.validate.min) }}"{% endif %} - {% if field.maxlength is defined or field.validate.max is defined %}maxlength="{{ field.maxlength | default(field.validate.max) }}"{% endif %} - {{ parent() }} +{% block global_attributes %} + data-grav-field="{{ field.type }}" + data-grav-disabled="{{ toggleable and toggleableChecked }}" + data-grav-default="{{ default ? default|json_encode()|safe_email|raw }}" +{% endblock %} + +{% block input %} +
+ {% block prepend %}{% endblock prepend %} + {% set input_value = value is iterable ? value|join(',') : value|string %} + + {% block append %}{% endblock append %} + {% if inline_errors and errors %} +
+

{{ errors|first|raw }}

+
+ {% endif %} +
{% endblock %}