8000 [TwigBridge] Fix HTML for translatable custom-file label in Bootstrap 4 theme by acran · Pull Request #40980 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Fix HTML for translatable custom-file label in Bootstrap 4 theme #40980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[TwigBridge] Fix HTML for translatable custom-file label in Bootstrap…
… 4 theme

Bootstraps allows to translate the label of the button of a custom-file
input with SCSS variables depending on the lang attribute of the
*input*.
This attribute was set on the label instead and thus had no effect.
  • Loading branch information
acran committed Apr 29, 2021
commit a95bbaaaef1f706836a59f021ac42cd5af576609
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@
{% block file_widget -%}
<{{ element|default('div') }} class="custom-file">
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
{%- set input_lang = 'en' -%}
{% if app is defined and app.request is defined %}{%- set input_lang = app.request.locale -%}{%- endif -%}
<label for="{{ form.vars.id }}" lang="{{ input_lang }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{%- set attr = {lang: input_lang} | merge(attr) -%}
{{- block('form_widget_simple') -}}
{%- 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 and attr.placeholder is not none -%}
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
{%- endif -%}
Expand Down
0