aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_tag_helper.rb
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2010-01-27 11:33:25 +0700
committerJosé Valim <jose.valim@gmail.com>2010-02-02 10:17:26 +0100
commitc01014ac1c98a05fe68e652f978dfa9d43f0fc2b (patch)
treec51a4852efa2f150cb39decd98ae17f20fdb5251 /actionpack/lib/action_view/helpers/form_tag_helper.rb
parentea2cbc86f7d73a4884a16530454908cff765c0dc (diff)
downloadrails-c01014ac1c98a05fe68e652f978dfa9d43f0fc2b.tar.gz
rails-c01014ac1c98a05fe68e652f978dfa9d43f0fc2b.tar.bz2
rails-c01014ac1c98a05fe68e652f978dfa9d43f0fc2b.zip
Modify the behavior of `radio_button_tag` to use `sanitize_to_id` for consistency [#1792 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 9b8471c6c6..ba1b0bcc20 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -329,9 +329,7 @@ module ActionView
# radio_button_tag 'color', "green", true, :class => "color_input"
# # => <input checked="checked" class="color_input" id="color_green" name="color" type="radio" value="green" />
def radio_button_tag(name, value, checked = false, options = {})
- pretty_tag_value = value.to_s.gsub(/\s/, "_").gsub(/(?!-)\W/, "").downcase
- pretty_name = name.to_s.gsub(/\[/, "_").gsub(/\]/, "")
- html_options = { "type" => "radio", "name" => name, "id" => "#{pretty_name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys)
+ html_options = { "type" => "radio", "name" => name, "id" => "#{sanitize_to_id(name)}_#{sanitize_to_id(value)}", "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked
tag :input, html_options
end