diff options
author | Tom Stuart <tom@experthuman.com> | 2011-02-12 11:34:49 +0000 |
---|---|---|
committer | Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com> | 2011-02-12 13:51:02 -0200 |
commit | 03749d6c88ae8312dc959b7683851dbf8c969326 (patch) | |
tree | de0ad9e7a607bc55b7681c7970d751d084a44be4 /actionpack/lib/action_view | |
parent | e8c870726a67a27965b2a5333a5ecf450d4f458f (diff) | |
download | rails-03749d6c88ae8312dc959b7683851dbf8c969326.tar.gz rails-03749d6c88ae8312dc959b7683851dbf8c969326.tar.bz2 rails-03749d6c88ae8312dc959b7683851dbf8c969326.zip |
Make type="submit" the default for button_tag helper
"submit" is the default value of the <button> element's type attribute
according to the HTML 4.01 and the HTML5 draft specs, so if button_tag
is going to have a default, type="submit" is a more sensible choice than
type="button".
http://www.w3.org/TR/html401/interact/forms.html#adef-type-BUTTON
http://dev.w3.org/html5/spec/the-button-element.html#attr-button-type
Signed-off-by: Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index d6b74974e9..c4a5a683d0 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -431,16 +431,16 @@ module ActionView # # ==== Examples # button_tag - # # => <button name="button" type="button">Button</button> + # # => <button name="button" type="submit">Button</button> # - # button_tag "<strong>Ask me!</strong>" + # button_tag "<strong>Ask me!</strong>", :type => 'button' # # => <button name="button" type="button"> # <strong>Ask me!</strong> # </button> # # button_tag "Checkout", :disable_with => "Please wait..." # # => <button data-disable-with="Please wait..." name="button" - # type="button">Checkout</button> + # type="submit">Checkout</button> # 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 |