Skip to content

Commit 0698c5d

Browse files
royklutmannicolas-grekas
authored andcommitted
[Twig] Replace for-loops with blocks for attributes
1 parent d44fd94 commit 0698c5d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
{% set label = name|humanize %}
9999
{%- endif -%}
100100
{%- endif -%}
101-
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
101+
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
102102
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
103103
</label>
104104
{%- endif -%}

Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
{%- endif -%}
249249

250250
{{ widget|raw }}
251-
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
251+
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
252252
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
253253
{{- form_errors(form) -}}
254254
</label>

Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
{%- else -%}
328328
{% set form_method = "POST" %}
329329
{%- endif -%}
330-
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
330+
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}>
331331
{%- if form_method != method -%}
332332
<input type="hidden" name="_method" value="{{ method }}" />
333333
{%- endif -%}

Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
{% set label = name|humanize %}
259259
{%- endif -%}
260260
{% endif %}
261-
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
261+
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
262262
{{ widget|raw }}
263263
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
264264
</label>

0 commit comments

Comments
 (0)