Skip to content

Commit

Permalink
feature #31220 [TwigBridge] bootstrap4 file_widget: allow setting lab…
Browse files Browse the repository at this point in the history
…el 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
  • Loading branch information
fabpot committed Apr 27, 2019
2 parents 6843905 + 9c76b29 commit 693094a
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -122,7 +122,8 @@
<{{ element|default('div') }} class="custom-file">
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
<label for="{{ form.vars.id }}" class="custom-file-label">
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{%- if attr.placeholder is defined -%}
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
{%- endif -%}
Expand Down

1 comment on commit 693094a

@cybernet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Please sign in to comment.