diff --git a/lib/bh/helpers/form/base_helper.rb b/lib/bh/helpers/form/base_helper.rb index 4eaed81..e4c9112 100644 --- a/lib/bh/helpers/form/base_helper.rb +++ b/lib/bh/helpers/form/base_helper.rb @@ -43,7 +43,11 @@ def field_in_group(field, prefix, suffix) end def input_addon(addon) - content_tag :span, addon, class: 'input-group-addon' if addon + if addon && addon.include?('class="btn') + content_tag :span, addon, class: 'input-group-btn' + elsif addon + content_tag :span, addon, class: 'input-group-addon' + end end def input_group_container(has_addons, &block) diff --git a/spec/helpers/form/field_helper_spec.rb b/spec/helpers/form/field_helper_spec.rb index d286434..8133cb6 100644 --- a/spec/helpers/form/field_helper_spec.rb +++ b/spec/helpers/form/field_helper_spec.rb @@ -56,6 +56,11 @@ def self.field_helpers_to_test it { expect(form).to match %r{
<.+?>Jr
}m } end + context 'given a suffix option that is a button, prints the correct addon wrapper class' do + let(:options) { {suffix: content_tag(:button, 'hey', class: 'btn btn-default')} } + it { expect(form).to match %r{
<.+?>
}m } + end + specify 'not given an error, does not apply has-error to the form group' do expect(form).not_to include 'has-error' end