diff --git a/Resources/doc/reference/form_types.rst b/Resources/doc/reference/form_types.rst index ff1e2acc8a..75a1839b25 100644 --- a/Resources/doc/reference/form_types.rst +++ b/Resources/doc/reference/form_types.rst @@ -147,3 +147,16 @@ The type has one extra parameter : 'choices' => Delivery::getStatusList(), 'catalogue' => 'SonataOrderBundle' )) + +Types options +------------- + +General +^^^^^^^ + +- ``label``: You can set the ``label`` option to ``false`` if you don't want to show it. + +.. code-block:: php + + add('status', null, array('label' => false); diff --git a/Resources/views/Form/form_admin_fields.html.twig b/Resources/views/Form/form_admin_fields.html.twig index 71fba1067e..ffa186beea 100755 --- a/Resources/views/Form/form_admin_fields.html.twig +++ b/Resources/views/Form/form_admin_fields.html.twig @@ -12,39 +12,41 @@ file that was distributed with this source code. {# Labels #} {% block form_label %} {% spaceless %} - {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ " control-label" }) %} + {% if label is not sameas(false) %} + {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ " control-label" }) %} - {% 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 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 %} + {% if label is empty %} + {% set label = name|humanize %} + {% endif %} - {% if in_list_checkbox is defined and in_list_checkbox and widget is defined %} - - {{ widget|raw }} - - {% if not sonata_admin.admin %} + {% if in_list_checkbox is defined and in_list_checkbox and widget is defined %} + + {{ widget|raw }} + + {% if not sonata_admin.admin %} + {{- label|trans({}, translation_domain) -}} + {% else %} + {{- label|trans({}, sonata_admin.admin.translationDomain) -}} + {% endif%} + + + {% else %} + + {% if not sonata_admin.admin%} {{- label|trans({}, translation_domain) -}} {% else %} - {{- label|trans({}, sonata_admin.admin.translationDomain) -}} - {% endif%} - - - {% else %} - - {% if not sonata_admin.admin%} - {{- label|trans({}, translation_domain) -}} - {% else %} - {{ sonata_admin.admin.trans(label) }} - {% endif %} - {{ required ? '*' : '' }} - + {{ sonata_admin.admin.trans(label) }} + {% endif %} + {{ required ? '*' : '' }} + + {% endif %} {% endif %} {% endspaceless %} {% endblock form_label %}