Override Form Field Rendering

06.09.2019 | Symfony | Twig

Overriding form_error block for all forms here. {# templates/Form/fields.html.twig #} {% block form_errors %} {% spaceless %} {% if errors|length > 0 %} <div class="alert alert-d

Overriding form_error block for all forms here.

{# templates/Form/fields.html.twig #}

{% block form_errors %}
	{% spaceless %}
		{% if errors|length > 0 %}
		<div class="alert alert-danger">
			<ul>
				{% for error in errors %}
					<li>{{ error.message }}</li>
				{% endfor %}
			</ul>
		</div>
		{% endif %}
	{% endspaceless %}
{% endblock form_errors %}

 

Add to form_themes in config/packages/twig.yaml

  form_themes:
    - 'Form/fields.html.twig'

 

Analyse

Entwurf

Development

Launch