From 3f497e9274f1f1fc99d9879627a7a954d7fa16bb Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 10 Dec 2013 23:41:45 +0100 Subject: [PATCH] allow more than two columns in horizontal form --- .../bootstrap_and_overrides.css.less | 18 ++++++++++++++---- app/views/articles/_form.html.haml | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 07553a8b..8d03444d 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -248,17 +248,21 @@ tr.unavailable { margin: 0; } -// two-column layout in forms (landscape tablet and wider only) +// multiple-column layout in forms (landscape tablet and wider only) @media (min-width: 768px) { - .form-horizontal .twocol { - .control-group:nth-child(odd) { + .form-horizontal .fold-line { + .control-group { float: left; } - .control-group:nth-child(even) { + .control-group + .control-group { .control-label { width: auto; margin: 0 10px; } + .controls { + float: left; + margin-left: 0; + } // fix margin somehow off // XXX there must be a better way margin-bottom: 0; @@ -267,6 +271,12 @@ tr.unavailable { margin-bottom: 20px; } } + .control-group:last-child { + float: none; + .controls { + float: none; + } + } } } // allow to have indicator text instead of input with same markup diff --git a/app/views/articles/_form.html.haml b/app/views/articles/_form.html.haml index 3fcb4e9b..b63db423 100644 --- a/app/views/articles/_form.html.haml +++ b/app/views/articles/_form.html.haml @@ -7,7 +7,7 @@ .modal-body = f.input :availability = f.input :name - .twocol + .fold-line = f.input :unit_quantity, label: Article.human_attribute_name(:unit), input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit_quantity)} = f.input :unit, label: '×'.html_safe, @@ -17,7 +17,7 @@ = f.association :article_category / TODO labels - .twocol + .fold-line = f.input :price do .input-prepend %span.add-on= t 'number.currency.format.unit' @@ -26,6 +26,7 @@ .input-append = f.input_field :tax, class: 'input-mini' %span.add-on % + .fold-line = f.input :deposit do .input-prepend %span.add-on= t 'number.currency.format.unit'