Add default css class to button, closes #36

This commit is contained in:
Carlos Antonio da Silva 2010-08-07 17:18:03 -03:00
parent cf997937e1
commit 4d6dd57f38
2 changed files with 5 additions and 2 deletions

View File

@ -159,6 +159,9 @@ module SimpleForm
# It just acts as a proxy to method name given. # It just acts as a proxy to method name given.
# #
def button(type, *args, &block) def button(type, *args, &block)
options = args.extract_options!
options[:class] = "button #{options[:class]}".strip
args << options
if respond_to?(:"#{type}_button") if respond_to?(:"#{type}_button")
send(:"#{type}_button", *args, &block) send(:"#{type}_button", *args, &block)
else else

View File

@ -394,13 +394,13 @@ class FormBuilderTest < ActionView::TestCase
# BUTTONS # BUTTONS
test 'builder should create buttons' do test 'builder should create buttons' do
with_button_for :post, :submit with_button_for :post, :submit
assert_select 'form input[type=submit][value=Save Post]' assert_select 'form input.button[type=submit][value=Save Post]'
end end
test 'builder should create buttons for records' do test 'builder should create buttons for records' do
@user.new_record! @user.new_record!
with_button_for @user, :submit with_button_for @user, :submit
assert_select 'form input[type=submit][value=Create User]' assert_select 'form input.button[type=submit][value=Create User]'
end end
# ASSOCIATIONS # ASSOCIATIONS