bug #42049 [TwigBridge] do not render the same label id attribute twice (xabbuh)
This PR was merged into the 4.4 branch.
Discussion
----------
[TwigBridge] do not render the same label id attribute twice
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #40562
| License | MIT
| Doc PR |
Commits
-------
ceee81e33d
do not render the same label id attribute twice
This commit is contained in:
commit
7385bc88d4
@ -122,7 +122,7 @@
|
|||||||
<{{ 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') -}}
|
||||||
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
|
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim })|filter((value, key) => key != 'id') -%}
|
||||||
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
||||||
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
|
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
|
||||||
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
|
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
|
||||||
|
@ -1088,6 +1088,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFileLabelIdNotDuplicated()
|
||||||
|
{
|
||||||
|
$form = $this->factory->createNamed('name', FileType::class);
|
||||||
|
|
||||||
|
$this->assertWidgetMatchesXpath($form->createView(), ['id' => 'n/a', 'attr' => ['class' => 'my&class form-control-file'], 'label_attr' => ['id' => 'label-id']],
|
||||||
|
'/div
|
||||||
|
[@class="custom-file"]
|
||||||
|
[
|
||||||
|
./input
|
||||||
|
[@type="file"]
|
||||||
|
[@name="name"]
|
||||||
|
/following-sibling::label
|
||||||
|
[@for="name"][not(@id)]
|
||||||
|
]
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFileWithPlaceholder()
|
public function testFileWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', FileType::class);
|
$form = $this->factory->createNamed('name', FileType::class);
|
||||||
|
Reference in New Issue
Block a user