[Twig] Replace for-loops with blocks for attributes

This commit is contained in:
Roy Klutman 2018-12-19 20:54:55 +01:00 committed by Nicolas Grekas
parent 88525d71bf
commit 0cd8088a6d
4 changed files with 4 additions and 4 deletions

View File

@ -98,7 +98,7 @@
{% set label = name|humanize %} {% set label = name|humanize %}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> <label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} {{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
</label> </label>
{%- endif -%} {%- endif -%}

View File

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

View File

@ -327,7 +327,7 @@
{%- else -%} {%- else -%}
{% set form_method = "POST" %} {% set form_method = "POST" %}
{%- endif -%} {%- endif -%}
<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 %}> <form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%} {%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}" /> <input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%} {%- endif -%}

View File

@ -258,7 +258,7 @@
{% set label = name|humanize %} {% set label = name|humanize %}
{%- endif -%} {%- endif -%}
{% endif %} {% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> <label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{{ widget|raw }} {{ widget|raw }}
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
</label> </label>