From 5b3a9854afac339fbbb4a07912cde14653eee6ab Mon Sep 17 00:00:00 2001 From: Michael Zorn Date: Sat, 17 Mar 2018 17:47:44 +0100 Subject: [PATCH 1/2] Updates help messages for horizontal forms test Updates test to reflect the changes made in form_group method --- test/bootstrap_form_group_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 44dfbb5c8..2d9fc0dfd 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -189,8 +189,8 @@ class BootstrapFormGroupTest < ActionView::TestCase
+ This is required
- This is required HTML assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required") From c2a94efa315edd6bd5fa8cd83540994083ba2f2f Mon Sep 17 00:00:00 2001 From: Michael Zorn Date: Sat, 17 Mar 2018 17:51:23 +0100 Subject: [PATCH 2/2] Moves help text in horiz. forms under the control When using horizontal forms the help text is placed inside the created row but as sibling of the cols for label and control. This codechange moves the help text inside the col of the control so it gets aligned with/under the control. --- lib/bootstrap_form/form_builder.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index ceca432a1..9068e6015 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -254,20 +254,20 @@ def form_group(*args, &block) label = generate_label(options[:id], name, options[:label], options[:label_col], options[:layout]) if options[:label] control = prepend_and_append_input(name, options, &block).to_s + help = options[:help] + help_text = generate_help(name, help).to_s + if get_group_layout(options[:layout]) == :horizontal control_class = options[:control_col] || control_col unless options[:label] control_offset = offset_col(options[:label_col] || @label_col) control_class = "#{control_class} #{control_offset}" end - control = content_tag(:div, control, class: control_class) + control = content_tag(:div, control + help_text, class: control_class) + concat(label).concat(control) + else + concat(label).concat(control).concat(help_text) end - - help = options[:help] - - help_text = generate_help(name, help).to_s - - concat(label).concat(control).concat(help_text) end end