Customizing Symfony Form Templates
Form errors
Form errors are rendered with a {% form_errors %} block.
Field errors are rendered with a {% field_errors %} block.
Global customization
Create a stand-along template that overrides the form_errors block:
{# app/Resources/views/form_theme.html.twig #}
{% block form_errors %}
<div class="alert alert-danger alert-form-errors">
{% for error in errors %}
<div>{{ error.messageTemplate|trans(error.messageParameters, 'validators') }}</div>
{% endfor %}
</div>
{% endblock %}
</syntaxhighlight>
Update the application configuration:
# app/config/config.yml # ... twig: form: resources: - 'form_theme.html.twig'