Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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