-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added safe_email filter for email field
Note: This requires grav 1.7.0-rc.18, as safe_email got fixed there: getgrav/grav@068de42
- Loading branch information
Showing
1 changed file
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %} | ||
<div class="{{ layout_form_field_wrapper_classes }} {{ field.size }}"> | ||
{% block prepend %}{% endblock prepend %} | ||
{% set input_value = value is iterable ? value|join(',') : value|string %} | ||
<input | ||
name="{{ (scope ~ field.name)|fieldName }}" | ||
value="{{ input_value|safe_email|raw }}" | ||
{% 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() }} | ||
{% endblock %} | ||
/> | ||
{% block append %}{% endblock append %} | ||
{% if inline_errors and errors %} | ||
<div class="{{ form_field_inline_error_classes }}"> | ||
<p class="form-message"><i class="fa fa-exclamation-circle"></i> {{ errors|first|raw }}</p> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |