1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Merge pull request #320 from sryche/master

Add a configuration option to change the class of buttons
This commit is contained in:
Rafael Mendonça França 2011-09-11 19:20:38 -07:00
commit 3eaefecd79
3 changed files with 12 additions and 1 deletions

View file

@ -108,6 +108,10 @@ module SimpleForm
mattr_accessor :cache_discovery
@@cache_discovery = !Rails.env.development?
# Adds a class to each generated button, mostly for compatiblity
mattr_accessor :button_class
@@button_class = 'button'
## WRAPPER CONFIGURATION
@@wrappers = {}

View file

@ -193,7 +193,7 @@ module SimpleForm
#
def button(type, *args, &block)
options = args.extract_options!
options[:class] = "button #{options[:class]}".strip
options[:class] = "#{SimpleForm.button_class} #{options[:class]}".strip
args << options
if respond_to?("#{type}_button")
send("#{type}_button", *args, &block)

View file

@ -18,4 +18,11 @@ class ButtonTest < ActionView::TestCase
with_button_for @user, :submit
assert_select 'form input.button[type=submit][value=Create User]'
end
test "builder should use the default class from the configuration" do
swap SimpleForm, :button_class => 'btn' do
with_button_for :post, :submit
assert_select 'form input.btn[type=submit][value=Save Post]'
end
end
end