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 e821ac9c5adbd..8f790fdd19450 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
@@ -119,7 +119,11 @@
<{{ element|default('div') }} class="custom-file">
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
-
+
{{ element|default('div') }}>
{% endblock %}
diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
index a3fc43a49f280..283757080bd55 100644
--- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
@@ -940,7 +940,7 @@ public function testFile()
{
$form = $this->factory->createNamed('name', FileType::class);
- $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'nope', 'attr' => array('class' => 'my&class form-control-file')),
+ $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file')),
'/div
[@class="form-group"]
[
@@ -958,6 +958,28 @@ public function testFile()
);
}
+ public function testFileWithPlaceholder()
+ {
+ $form = $this->factory->createNamed('name', FileType::class);
+
+ $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder')),
+'/div
+ [@class="form-group"]
+ [
+ ./div
+ [@class="custom-file"]
+ [
+ ./input
+ [@type="file"]
+ [@name="name"]
+ /following-sibling::label
+ [@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
+ ]
+ ]
+'
+ );
+ }
+
public function testMoney()
{
$form = $this->factory->createNamed('name', MoneyType::class, 1234.56, array(