Skip to content

Commit

Permalink
Merge pull request #1 from tekkla/tekkla-horizontal-form-patch
Browse files Browse the repository at this point in the history
Updates help messages for horizontal forms test
  • Loading branch information
Michael Zorn committed Mar 17, 2018
2 parents e983aa1 + 25015aa commit 6babf6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/bootstrap_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap_form_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ class BootstrapFormGroupTest < ActionView::TestCase
<label class="col-form-label col-sm-2 required" for="user_email">Email</label>
<div class="col-sm-10">
<input class="form-control" id="user_email" name="user[email]" type="text" value="steve@example.com" />
<small class="form-text text-muted">This is required</small>
</div>
<small class="form-text text-muted">This is required</small>
</div>
HTML
assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required")
Expand Down

0 comments on commit 6babf6f

Please sign in to comment.