Skip to content

Commit b2e50bb

Browse files
committed
render errors as part of the label only
1 parent e32b518 commit b2e50bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@
207207
{% set label = name|humanize %}
208208
{%- endif -%}
209209
{%- endif -%}
210-
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
210+
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% block form_label_errors %}{{- form_errors(form, _context|merge({'render_errors': true})) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
211211
{%- else -%}
212212
{%- if errors|length > 0 -%}
213213
<div id="{{ id }}_errors" class="mb-2">
214-
{{- form_errors(form) -}}
214+
{{- form_errors(form, _context|merge({'render_errors': true})) -}}
215215
</div>
216216
{%- endif -%}
217217
{%- endif -%}
@@ -250,7 +250,7 @@
250250
{{ widget|raw }}
251251
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
252252
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
253-
{{- form_errors(form) -}}
253+
{{- form_errors(form, _context|merge({'render_errors': true})) -}}
254254
</label>
255255
{%- endif -%}
256256
{%- endblock checkbox_radio_label %}
@@ -270,7 +270,7 @@
270270
{# Errors #}
271271

272272
{% block form_errors -%}
273-
{%- if errors|length > 0 -%}
273+
{%- if render_errors|default(false) and errors|length > 0 -%}
274274
<span class="{% if form is not rootform %}invalid-feedback{% else %}alert alert-danger{% endif %} d-block">
275275
{%- for error in errors -%}
276276
<span class="d-block">

0 commit comments

Comments
 (0)