Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7e67d8

Browse files
committed
[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.
1 parent 00764dd commit b7e67d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@
121121
{% block file_widget -%}
122122
<{{ element|default('div') }} class="custom-file">
123123
{%- set type = type|default('file') -%}
124-
{{- block('form_widget_simple') -}}
125-
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
126124
{%- set input_lang = 'en' -%}
127125
{% if app is defined and app.request is defined %}{%- set input_lang = app.request.locale -%}{%- endif -%}
128-
<label for="{{ form.vars.id }}" lang="{{ input_lang }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
126+
{%- set attr = {lang: input_lang} | merge(attr) -%}
127+
{{ block('form_widget_simple') }}
128+
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
129+
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
129130
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
130131
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
131132
{%- endif -%}

0 commit comments

Comments
 (0)