Permalink
Browse files

Fixed that radio_button_tag should generate unique ids (closes #3353)…

… [BobSilva/rebecca/josh]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 46b0e7d commit 62a9203a5ed43fb3aea742b887a3bc874352950a @dhh dhh committed Jun 23, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that radio_button_tag should generate unique ids #3353 [BobSilva/rebecca/josh]
+
* Fixed that HTTP authentication should work if the header is called REDIRECT_X_HTTP_AUTHORIZATION as well #6754 [mislaw]
* Don't mistakenly interpret the request uri as the query string. #8731 [lifofifo, Jeremy Kemper]
@@ -122,7 +122,8 @@ def check_box_tag(name, value = "1", checked = false, options = {})
# Creates a radio button.
def radio_button_tag(name, value, checked = false, options = {})
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)
+ pretty_name = name.gsub(/\[/, "_").gsub(/\]/, "")
+ html_options = { "type" => "radio", "name" => name, "id" => "#{pretty_name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked
tag :input, html_options
end
@@ -93,6 +93,9 @@ def test_radio_button_tag
expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />)
assert_dom_equal expected, actual
+ actual = radio_button_tag("person[gender]", "m")
+ expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />)
+ assert_dom_equal expected, actual
end
def test_select_tag

0 comments on commit 62a9203

Please sign in to comment.