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

Skip to content

Commit 120547c

Browse files
committed
[Form][TwigBridge] Don't set label attributes if is marked as not to be rendered
[Form][FrameworkBundle] Add option to disable rendering of label for fields
1 parent 36e4556 commit 120547c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@
221221

222222
{% block form_label %}
223223
{% spaceless %}
224-
{% if not compound %}
225-
{% set label_attr = label_attr|merge({'for': id}) %}
226-
{% endif %}
227-
{% if required %}
228-
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
229-
{% endif %}
230224
{% if label is not sameas(false) %}
225+
{% if not compound %}
226+
{% set label_attr = label_attr|merge({'for': id}) %}
227+
{% endif %}
228+
{% if required %}
229+
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
230+
{% endif %}
231231
{% if label is empty %}
232232
{% set label = name|humanize %}
233233
{% endif %}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
<?php if (false !== $label): ?>
12
<?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?>
23
<?php if (!$compound) { $label_attr['for'] = $id; } ?>
34
<?php if (!$label) { $label = $view['form']->humanize($name); } ?>
45
<label <?php foreach ($label_attr as $k => $v) { printf('%s="%s" ', $view->escape($k), $view->escape($v)); } ?>><?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
6+
<?php endif ?>

0 commit comments

Comments
 (0)