From aa4e1b1a7b5fb3f2386136820c4478acca86bb14 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Fri, 27 Oct 2017 04:40:00 +0300 Subject: [PATCH 1/2] Fix unnecessary legend class Do not add .form-control-label and .col-form-legend at the same time. It's enough to have only one of them. --- .../Twig/Resources/views/Form/bootstrap_4_layout.html.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 7dda32ace2fc4..468bbb87cbe6d 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -73,8 +73,9 @@ {%- if expanded is defined and expanded -%} {%- set element = 'legend' -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%} + {%- else -%} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} {%- endif -%} - {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} {{- parent() -}} {%- endblock form_label %} From 7b8b9d143bc2825ef69c94b5853894184a828525 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Fri, 27 Oct 2017 04:48:17 +0300 Subject: [PATCH 2/2] Use legends instead of labels for compound fields I think it makes more sense to have nested `fieldset`s than `label`s without `for`. An example of nested fieldsets is given at the bottom of [this page](https://dev.w3.org/html5/spec-preview/the-fieldset-element.html). --- .../Twig/Resources/views/Form/bootstrap_4_layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 468bbb87cbe6d..f9cb62209daf3 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -70,7 +70,7 @@ {# Labels #} {% block form_label -%} - {%- if expanded is defined and expanded -%} + {%- if compound is defined and compound -%} {%- set element = 'legend' -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%} {%- else -%} @@ -108,7 +108,7 @@ {# Rows #} {% block form_row -%} - {%- if expanded is defined and expanded -%} + {%- if compound is defined and compound -%} {%- set element = 'fieldset' -%} {%- endif -%} <{{ element|default('div') }} class="form-group">