From 4fc6c872ef1f6ae10eec7c24cbc60697336ca707 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 3 Sep 2006 19:32:31 +0000 Subject: radio_button_tag generates unique id attributes. Closes #3353. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4925 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 816f1064f7..e023fe93d2 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -125,7 +125,8 @@ module ActionView # Creates a radio button. def radio_button_tag(name, value, checked = false, options = {}) - html_options = { "type" => "radio", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys) + pretty_tag_value = value.to_s.gsub(/\s/, "_").gsub(/(?!-)\W/, "").downcase + html_options = { "type" => "radio", "name" => name, "id" => "#{name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys) html_options["checked"] = "checked" if checked tag :input, html_options end -- cgit v1.2.3