8000 feature #31220 [TwigBridge] bootstrap4 file_widget: allow setting lab… · symfony/symfony@693094a · GitHub
[go: up one dir, main page]

Skip to content

Commit 693094a

Browse files
committed
feature #31220 [TwigBridge] bootstrap4 file_widget: allow setting label attributes declared in label_attr (AngelFQC)
This PR was submitted for the 4.2 branch but it was merged into the 4.3-dev branch instead (closes #31220). Discussion ---------- [TwigBridge] bootstrap4 file_widget: allow setting label attributes declared in label_attr | Q | A | ------------- | --- | Branch? | 4.2 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | ... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | ... <!-- required for new features --> > Bootstrap provides a way to translate the “Browse” text in HTML with the data-browse attribute which can be added to the custom input label. https://getbootstrap.com/docs/4.3/components/forms/#translating-or-customizing-the-strings-with-html But currently the attributes declared in label_attr aren't being added. Previously I sent this same change to the master branch (PR #31102), but I think I should have sent it to branch 4.2 Commits ------- 9c76b29 [TwigBridge] bootstrap4 file_widget: allow setting label attributes declared in label_attr
2 parents 6843905 + 9c76b29 commit 693094a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@
122122
<{{ element|default('div') }} class="custom-file">
123123
{%- set type = type|default('file') -%}
124124
{{- block('form_widget_simple') -}}
125-
<label for="{{ form.vars.id }}" class="custom-file-label">
125+
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
126+
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
126127
{%- if attr.placeholder is defined -%}
127128
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
128129
{%- endif -%}

0 commit comments

Comments
 (0)
0