bug #27958 [Form] Remaining changes for bootstrap 4 file fields (apfelbox)
This PR was merged into the 4.1 branch.
Discussion
----------
[Form] Remaining changes for bootstrap 4 file fields
| Q | A
| ------------- | ---
| Branch? | 4.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no>
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | —
| License | MIT
| Doc PR | —
Hi again,
This is a follow-up PR for #27919
Apparently I talked about it in the previous PR, but forgot to actually push the change. Sorry about that! 😞
This PR no actually adds this instead of just talking about it:
![2018-07-15 at 17 52](https://user-images.githubusercontent.com/1032411/42735630-e19b22be-8857-11e8-85b8-6d64e17c2be2.png)
Sorry again, just forgot to actually update the last PR.
Commits
-------
3cd2eef6e6
Add placeholder support in bootstrap 4 file fields
This commit is contained in:
commit
e247b1dfd9
@ -119,7 +119,11 @@
|
|||||||
<{{ element|default('div') }} class="custom-file">
|
<{{ element|default('div') }} class="custom-file">
|
||||||
{%- set type = type|default('file') -%}
|
{%- set type = type|default('file') -%}
|
||||||
{{- block('form_widget_simple') -}}
|
{{- 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') }}>
|
</{{ element|default('div') }}>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -940,7 +940,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
|
|||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', FileType::class);
|
$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
|
'/div
|
||||||
[@class="form-group"]
|
[@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()
|
public function testMoney()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', MoneyType::class, 1234.56, array(
|
$form = $this->factory->createNamed('name', MoneyType::class, 1234.56, array(
|
||||||
|
Reference in New Issue
Block a user