From 8ef9f4850d1a0175ff4617889807433471fee032 Mon Sep 17 00:00:00 2001 From: Tom Stuart Date: Sat, 12 Feb 2011 11:34:49 +0000 Subject: [PATCH 1/2] Make type="submit" the default for button_tag helper "submit" is the default value of the + # # => # - # button_tag "Ask me!" + # button_tag "Ask me!", :type => 'button' # # => # # button_tag "Checkout", :disable_with => "Please wait..." # # => + # type="submit">Checkout # def button_tag(label = "Button", options = {}) options.stringify_keys! @@ -453,9 +453,7 @@ module ActionView options["data-confirm"] = confirm end - ["type", "name"].each do |option| - options[option] = "button" unless options[option] - end + options.reverse_merge! 'name' => 'button', 'type' => 'submit' content_tag :button, label, { "type" => options.delete("type") }.update(options) end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 4a584b8..c22af25 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -387,7 +387,7 @@ class FormTagHelperTest < ActionView::TestCase def test_button_tag assert_dom_equal( - %(), + %(), button_tag ) end @@ -399,6 +399,13 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_button_tag_with_button_type + assert_dom_equal( + %(), + button_tag("Button", :type => "button") + ) + end + def test_button_tag_with_reset_type assert_dom_equal( %(), -- 1.7.2