From 2e4d2b5d9dbf65151d860048998135618c2b8357 Mon Sep 17 00:00:00 2001 From: Dennis Krupenik Date: Mon, 13 Apr 2009 01:45:00 +0300 Subject: [PATCH] Added :form_class option to UrlHelper#button_to --- actionpack/lib/action_view/helpers/url_helper.rb | 8 +++++++- actionpack/test/template/url_helper_test.rb | 4 ++++ 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 36e0a78..e7641f5 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -267,6 +267,8 @@ module ActionView # * :confirm - This will add a JavaScript confirm # prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. + # * :form_class - Specifies the class of the generated form. + # Defaults to "button-to". # # ==== Examples # <%= button_to "New", :action => "new" %> @@ -308,7 +310,11 @@ module ActionView html_options.merge!("type" => "submit", "value" => name) - "
" + + unless form_class = html_options.delete("form_class") + form_class = "button-to" + end + + "
" + method_tag + tag("input", html_options) + request_token_tag + "
" end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 5900709..590dcb9 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -87,6 +87,10 @@ class UrlHelperTest < ActionView::TestCase button_to("Hello", "http://www.example.com", :method => :get) ) end + + def test_button_to_with_custom_form_class + assert_dom_equal "
", button_to("Hello", "http://www.example.com", :form_class => "custom") + end def test_link_tag_with_straight_url assert_dom_equal "Hello", link_to("Hello", "http://www.example.com") -- 1.6.2.2