bug #17382 [TwigBridge] Use label_format option for checkbox and radio labels (enumag)

This PR was merged into the 2.8 branch.

Discussion
----------

[TwigBridge] Use label_format option for checkbox and radio labels

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

6fbd9a7 [TwigBridge] Use label_format option for checkbox and radio labels
This commit is contained in:
Fabien Potencier 2016-01-15 18:05:52 +01:00
commit 3223c2517e

View File

@ -249,7 +249,14 @@
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %}
{% endif %}
{% if label is empty %}
{% set label = name|humanize %}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ widget|raw }}