Add placeholder support in bootstrap 4 file fields
This commit is contained in:
parent
25df3e32cb
commit
3cd2eef6e6
@ -119,7 +119,11 @@
|
||||
<{{ element|default('div') }} class="custom-file">
|
||||
{%- set type = type|default('file') -%}
|
||||
{{- block('form_widget_simple') -}}
|
||||
<label for="{{ form.vars.id }}" class="custom-file-label">Choose File</label>
|
||||
<label for="{{ form.vars.id }}" class="custom-file-label">
|
||||
{%- if attr.placeholder is defined -%}
|
||||
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
|
||||
{%- endif -%}
|
||||
</label>
|
||||
</{{ element|default('div') }}>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user