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 e821ac9c5a..8f790fdd19 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 a3fc43a49f..283757080b 100644
--- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
@@ -940,7 +940,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
{
$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 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
);
}
+ 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(