Skip to content

Commit 2a7cbd3

Browse files
committed
Merge pull request bootstrap-ruby#80 from rzane/dont-reset-form-group-class
Dont reset additional classes on the form-group
2 parents 098b0e9 + 0867d7d commit 2a7cbd3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/bootstrap_form/form_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def radio_buttons_collection(*args)
121121
end
122122

123123
def form_group(name = nil, options = {}, &block)
124-
options[:class] = "form-group"
124+
options[:class] = ["form-group", options[:class]].compact.join(' ')
125125
options[:class] << " #{error_class}" if has_error?(name)
126126

127127
content_tag(:div, options.except(:label, :help, :label_col, :control_col, :layout)) do

test/bootstrap_form_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ def setup
419419
assert_equal expected, output
420420
end
421421

422+
test "form_group accepts class thorugh options hash" do
423+
output = @horizontal_builder.form_group :email, class: "foo" do
424+
%{<p class="form-control-static">Bar</p>}.html_safe
425+
end
426+
427+
expected = %{<div class="form-group foo"><label class="control-label col-sm-2"></label><div class="col-sm-10"><p class="form-control-static">Bar</p></div></div>}
428+
assert_equal expected, output
429+
end
430+
422431
test "static control" do
423432
output = @horizontal_builder.static_control :email
424433

0 commit comments

Comments
 (0)