Skip to content

Commit 856f21a

Browse files
committed
bug symfony#24703 [TwigBridge] Bootstrap 4 form theme fixes (vudaltsov)
This PR was squashed before being merged into the 3.4 branch (closes symfony#24703). Discussion ---------- [TwigBridge] Bootstrap 4 form theme fixes | Q | A | ------------- | --- | Branch? | 3.4 and higher | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Some fixes for compound forms and their labels. 1. Do not add `.form-control-label` and `.col-form-legend` at the same time. It's enough to have only one of them. 1. Use legends instead of labels for compound fields. I think it makes more sense to have nested `fieldsets` than `labels` without `for` in a compound form. An example of nested fieldsets is given at the bottom of [this page](https://dev.w3.org/html5/spec-preview/the-fieldset-element.html). Commits ------- e55c67a [TwigBridge] Bootstrap 4 form theme fixes
2 parents e839df9 + e55c67a commit 856f21a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@
7070
{# Labels #}
7171

7272
{% block form_label -%}
73-
{%- if expanded is defined and expanded -%}
73+
{%- if compound is defined and compound -%}
7474
{%- set element = 'legend' -%}
7575
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%}
76+
{%- else -%}
77+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
7678
{%- endif -%}
77-
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
7879
{{- parent() -}}
7980
{%- endblock form_label %}
8081

@@ -107,7 +108,7 @@
107108
{# Rows #}
108109

109110
{% block form_row -%}
110-
{%- if expanded is defined and expanded -%}
111+
{%- if compound is defined and compound -%}
111112
{%- set element = 'fieldset' -%}
112113
{%- endif -%}
113114
<{{ element|default('div') }} class="form-group">

0 commit comments

Comments
 (0)