diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 457b1a55..d099c4e5 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -203,8 +203,12 @@ module SimpleForm # f.button :submit # end # - # It just acts as a proxy to method name given. + # It just acts as a proxy to method name given. We also alias original Rails + # button implementation (3.2 forward (to delegate to the original when + # calling `f.button :button`. # + # TODO: remove if condition when supporting only Rails 3.2 forward. + alias_method :button_button, :button if method_defined?(:button) def button(type, *args, &block) options = args.extract_options! options[:class] = [SimpleForm.button_class, options[:class]].compact diff --git a/test/form_builder/button_test.rb b/test/form_builder/button_test.rb index af8e3534..7e29d3e7 100644 --- a/test/form_builder/button_test.rb +++ b/test/form_builder/button_test.rb @@ -25,4 +25,11 @@ class ButtonTest < ActionView::TestCase assert_select 'form input.btn[type=submit][value=Save Post]' end end + + if ActionView::Helpers::FormBuilder.method_defined?(:button) + test "allows to use Rails button helper when available" do + with_button_for :post, :button, 'Save!' + assert_select 'form button.button[type=submit]', 'Save!' + end + end end