Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e47827

Browse files
bug #28115 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4 (MrMitch)
This PR was merged into the 4.1 branch. Discussion ---------- [Form] Remove extra .form-group wrapper around file widget in bootstrap 4 | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This is a follow-up to #27958 and #27919 by @apfelbox . It fixes an extra space between the help text of a FileType widget and the widget itself. The extra space was caused by a `.form-group` wrapper in the `file_widget` block. Commits ------- 01e7fe4 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4
2 parents d59e97f + 01e7fe4 commit 3e47827

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,15 @@
115115
{%- endblock percent_widget %}
116116

117117
{% block file_widget -%}
118-
<div class="form-group">
119-
<{{ element|default('div') }} class="custom-file">
120-
{%- set type = type|default('file') -%}
121-
{{- block('form_widget_simple') -}}
122-
<label for="{{ form.vars.id }}" class="custom-file-label">
123-
{%- if attr.placeholder is defined -%}
124-
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
125-
{%- endif -%}
126-
</label>
127-
</{{ element|default('div') }}>
128-
</div>
118+
<{{ element|default('div') }} class="custom-file">
119+
{%- set type = type|default('file') -%}
120+
{{- block('form_widget_simple') -}}
121+
<label for="{{ form.vars.id }}" class="custom-file-label">
122+
{%- if attr.placeholder is defined -%}
123+
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
124+
{%- endif -%}
125+
</label>
126+
</{{ element|default('div') }}>
129127
{% endblock %}
130128

131129
{% block form_widget_simple -%}

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -942,17 +942,13 @@ public function testFile()
942942

943943
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file')),
944944
'/div
945-
[@class="form-group"]
945+
[@class="custom-file"]
946946
[
947-
./div
948-
[@class="custom-file"]
949-
[
950-
./input
951-
[@type="file"]
952-
[@name="name"]
953-
/following-sibling::label
954-
[@for="name"]
955-
]
947+
./input
948+
[@type="file"]
949+
[@name="name"]
950+
/following-sibling::label
951+
[@for="name"]
956952
]
957953
'
958954
);
@@ -964,17 +960,13 @@ public function testFileWithPlaceholder()
964960

965961
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder')),
966962
'/div
967-
[@class="form-group"]
963+
[@class="custom-file"]
968964
[
969-
./div
970-
[@class="custom-file"]
971-
[
972-
./input
973-
[@type="file"]
974-
[@name="name"]
975-
/following-sibling::label
976-
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
977-
]
965+
./input
966+
[@type="file"]
967+
[@name="name"]
968+
/following-sibling::label
969+
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
978970
]
979971
'
980972
);

0 commit comments

Comments
 (0)