Permalink
Browse files

[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
  • Loading branch information...
stloyd committed Dec 11, 2012
1 parent 36e4556 commit 120547c8bcdc530f00508c0ab3abb3a6e04a2cc6
@@ -221,13 +221,13 @@
{% block form_label %}
{% spaceless %}
- {% if not compound %}
- {% set label_attr = label_attr|merge({'for': id}) %}
- {% endif %}
- {% if required %}
- {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
- {% endif %}
{% if label is not sameas(false) %}
+ {% if not compound %}
+ {% set label_attr = label_attr|merge({'for': id}) %}
+ {% endif %}
+ {% if required %}
+ {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
+ {% endif %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
@@ -1,4 +1,6 @@
+<?php if (false !== $label): ?>
<?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?>
<?php if (!$compound) { $label_attr['for'] = $id; } ?>
<?php if (!$label) { $label = $view['form']->humanize($name); } ?>
<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>
+<?php endif ?>

0 comments on commit 120547c

Please sign in to comment.