Skip to content

Commit 3223c25

Browse files
committed
bug symfony#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
2 parents 4d99d4d + 6fbd9a7 commit 3223c25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,14 @@
249249
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %}
250250
{% endif %}
251251
{% if label is empty %}
252-
{% set label = name|humanize %}
252+
{%- if label_format is not empty -%}
253+
{% set label = label_format|replace({
254+
'%name%': name,
255+
'%id%': id,
256+
}) %}
257+
{%- else -%}
258+
{% set label = name|humanize %}
259+
{%- endif -%}
253260
{% endif %}
254261
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
255262
{{ widget|raw }}

0 commit comments

Comments
 (0)