From 01e7fe4fb03aab19345a35f243aae8be8139f98a Mon Sep 17 00:00:00 2001 From: Mickael GOETZ Date: Thu, 2 Aug 2018 13:27:22 +0200 Subject: [PATCH] [Form] Remove extra .form-group wrapper around file widget in bootstrap 4 This is a follow-up to https://github.com/symfony/symfony/pull/27958 and https://github.com/symfony/symfony/pull/27919. It fixes an extra space between the help text of a FileType widget and the widget itself. The extra space was cause by a .form-group wrapper in the file_widget block. --- .../views/Form/bootstrap_4_layout.html.twig | 20 ++++++------ .../AbstractBootstrap4LayoutTest.php | 32 +++++++------------ 2 files changed, 21 insertions(+), 31 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 8f790fdd1945..5030264c127b 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 @@ -115,17 +115,15 @@ {%- endblock percent_widget %} {% block file_widget -%} -
- <{{ element|default('div') }} class="custom-file"> - {%- set type = type|default('file') -%} - {{- block('form_widget_simple') -}} - - -
+ <{{ element|default('div') }} class="custom-file"> + {%- set type = type|default('file') -%} + {{- block('form_widget_simple') -}} + + {% endblock %} {% block form_widget_simple -%} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php index 1336405bdd30..5710a2d486c0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php @@ -942,17 +942,13 @@ public function testFile() $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file')), '/div - [@class="form-group"] + [@class="custom-file"] [ - ./div - [@class="custom-file"] - [ - ./input - [@type="file"] - [@name="name"] - /following-sibling::label - [@for="name"] - ] + ./input + [@type="file"] + [@name="name"] + /following-sibling::label + [@for="name"] ] ' ); @@ -964,17 +960,13 @@ public function testFileWithPlaceholder() $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder')), '/div - [@class="form-group"] + [@class="custom-file"] [ - ./div - [@class="custom-file"] - [ - ./input - [@type="file"] - [@name="name"] - /following-sibling::label - [@for="name" and text() = "[trans]Custom Placeholder[/trans]"] - ] + ./input + [@type="file"] + [@name="name"] + /following-sibling::label + [@for="name" and text() = "[trans]Custom Placeholder[/trans]"] ] ' );