From 1706e4253abe2aeccba59ec2189e4d764f891b22 Mon Sep 17 00:00:00 2001 From: Florian Eckerstorfer Date: Sat, 28 Dec 2013 09:44:28 +0100 Subject: [PATCH] Fix setting style on subform. Finally fix #161 --- Resources/less/form.less | 7 +++++++ Resources/views/Form/bootstrap.html.twig | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Resources/less/form.less b/Resources/less/form.less index 55850f8..701ec84 100644 --- a/Resources/less/form.less +++ b/Resources/less/form.less @@ -37,6 +37,13 @@ } } +.form-inline { + .form-group + .form-group { + margin-left: 0; + margin-right: 0; + } +} + .form-horizontal { .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg12 { .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, diff --git a/Resources/views/Form/bootstrap.html.twig b/Resources/views/Form/bootstrap.html.twig index 375c73e..3171ecb 100644 --- a/Resources/views/Form/bootstrap.html.twig +++ b/Resources/views/Form/bootstrap.html.twig @@ -825,6 +825,9 @@ {% if attr.simple_col is defined %} {% set childAttr = childAttr|merge({ 'simple_col': attr.simple_col }) %} {% endif %} + {% if attr.style is defined %} + {% set childAttr = childAttr|merge({ 'style': attr.style }) %} + {% endif %} {{ form_row(child, childAttr) }} {% endfor %} {% endspaceless %} @@ -839,8 +842,12 @@ {% block widget_container_attributes %} {% spaceless %} + {% if attr.style == 'inline' or attr.style == 'horizontal' %} + {% set attr = attr|merge({ 'class': 'form-'~attr.style~attr.class|default('') }) %} + {% set attr = attr|merge({ 'style': null }) %} + {% endif %} {% if id is not empty %}id="{{ id }}" {% endif %} - {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} + {% for attrname, attrvalue in attr %}{% if attrvalue is not null %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} {% endspaceless %} {% endblock widget_container_attributes %}