Browse Source

Fix not aligned checkbox and radio on horizontal form (#3962)

With Twitter Bootstrap, checkbox and radio inputs need a col-sm-offset-* class to get aligned with the other inputs.
Sullivan SENECHAL 9 years ago
parent
commit
80db991c15
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Resources/views/Form/form_admin_fields.html.twig

+ 2 - 1
Resources/views/Form/form_admin_fields.html.twig

@@ -324,7 +324,8 @@ file that was distributed with this source code.
         {% endif %}
         {% endif %}
 
 
         {% if sonata_admin is defined and sonata_admin.options['form_type'] == 'horizontal' %}
         {% if sonata_admin is defined and sonata_admin.options['form_type'] == 'horizontal' %}
-            {% if label is same as(false) %}
+            {# Add an offset if no label or is a checkbox/radio #}
+            {% if label is same as(false) or form.vars.checked is defined %}
                 {% if 'collection' in form.parent.vars.block_prefixes %}
                 {% if 'collection' in form.parent.vars.block_prefixes %}
                     {% set div_class = div_class ~ ' col-sm-12' %}
                     {% set div_class = div_class ~ ' col-sm-12' %}
                 {% else %}
                 {% else %}