diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:50:41 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:50:41 +0000 |
commit | dfac1cea3d851000116a23ab14c2b1ae981f7a12 (patch) | |
tree | 91abe3727d19f4c13affe1a2e4bc4637b35d5fdf /actionpack/lib/action_view/helpers/form_tag_helper.rb | |
parent | db41d2dd5c738ca44a07330cf02e9d817fedc34c (diff) | |
download | rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.tar.gz rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.tar.bz2 rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.zip |
Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@833 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index a5b18fe7f0..60e3bbb67b 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -6,21 +6,20 @@ module ActionView # Provides a number of methods for creating form tags that doesn't rely on conventions with an object assigned to the template like # FormHelper does. With the FormTagHelper, you provide the names and values yourself. module FormTagHelper - # Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like + # Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like # ActionController::Base#url_for. The method for the form defaults to POST. # # Options: # * <tt>:multipart</tt> - If set to true, the enctype is set to "multipart/form-data". def form_tag(url_for_options = {}, options = {}, *parameters_for_url) - html_options = { "method" => "post" }.merge(options) - + html_options = { "method" => "post" }.merge(options.stringify_keys) + if html_options[:multipart] html_options["enctype"] = "multipart/form-data" html_options.delete(:multipart) end - + html_options["action"] = url_for(url_for_options, *parameters_for_url) - tag("form", html_options, true) end @@ -32,48 +31,49 @@ module ActionView end def select_tag(name, option_tags = nil, options = {}) - content_tag("select", option_tags, { "name" => name, "id" => name }.update(options)) + content_tag("select", option_tags, { "name" => name, "id" => name }.update(options.stringify_keys)) end def text_field_tag(name, value = nil, options = {}) - tag("input", {"type" => "text", "name" => name, "id" => name, "value" => value}.update(options)) + tag("input", { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)) end def hidden_field_tag(name, value = nil, options = {}) - text_field_tag(name, value, options.update("type" => "hidden")) + text_field_tag(name, value, options.stringify_keys.update("type" => "hidden")) end def file_field_tag(name, options = {}) - text_field_tag(name, nil, options.update("type" => "file")) + text_field_tag(name, nil, options.stringify_keys.update("type" => "file")) end def password_field_tag(name = "password", value = nil, options = {}) - text_field_tag(name, value, options.update("type" => "password")) + text_field_tag(name, value, options.stringify_keys.update("type" => "password")) end def text_area_tag(name, content = nil, options = {}) - if options[:size] - options["cols"], options["rows"] = options[:size].split("x") - options.delete(:size) + options = options.stringify_keys + if options["size"] + options["cols"], options["rows"] = options["size"].split("x") + options.delete("size") end - - content_tag("textarea", content, { "name" => name, "id" => name }.update(options)) + + content_tag("textarea", content, { "name" => name, "id" => name }.update(options.stringify_keys)) end def check_box_tag(name, value = "1", checked = false, options = {}) - html_options = {"type" => "checkbox", "name" => name, "id" => name, "value" => value}.update(options) + html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys) html_options["checked"] = "checked" if checked tag("input", html_options) end def radio_button_tag(name, value, checked = false, options = {}) - html_options = {"type" => "radio", "name" => name, "id" => name, "value" => value}.update(options) + html_options = { "type" => "radio", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys) html_options["checked"] = "checked" if checked tag("input", html_options) end def submit_tag(value = "Save changes", options = {}) - tag("input", {"type" => "submit", "name" => "submit", "value" => value}.update(options)) + tag("input", { "type" => "submit", "name" => "submit", "value" => value }.update(options.stringify_keys)) end end end |