You can customize how form errors render by providing your own form theme with a field_errors
block.
You can do this for just the current template:
{# tell the form to look for theme blocks in the current template #}
{% form_theme form _self %}
{% block field_errors %}
{% for error in errors %}
{{ error.messageTemplate|trans(error.messageParameters, 'validators') }}
{% endfor %}
{% endblock %}
{# the rest of your template... #}
Or by defining a global form theme in config.yml
:
twig:
form: { resource: "::form_theme.html.twig" }
In this case you would want to move the field_errors
block above to app/Resources/views/form_theme.html.twig
and the form_theme
tag is no longer necessary.