Permalink
Browse files

Fixed missing id uniqueness in FormTag#radio_button #1207 [Jarkko]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1253 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 14860eb commit 98306bed054c320833d9d48229c68da10a38f3d0 @dhh dhh committed Apr 30, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed missing id uniqueness in FormTag#radio_button #1207 [Jarkko]
+
* Fixed assert_redirected_to to work with :only_path => false #1204 [Alisdair McDiarmid]
* Fixed render_partial_collection to output an empty string instead of nil when handed an empty array #1202 [Ryan Carver]
@@ -175,6 +175,10 @@ def to_radio_button_tag(tag_value, options = {})
options["type"] = "radio"
options["value"] = tag_value
options["checked"] = "checked" if value == tag_value
+ pretty_tag_value = tag_value.gsub(/\s/, "_").gsub(/\W/, "").downcase
+ options["id"] = @auto_index ?
+ "#{@object_name}_#{@auto_index}_#{@method_name}_#{pretty_tag_value}" :
+ "#{@object_name}_#{@method_name}_#{pretty_tag_value}"
add_default_name_and_id(options)
tag("input", options)
end
@@ -82,10 +82,10 @@ def test_check_box
end
def test_radio_button
- assert_equal('<input checked="checked" id="post_title" name="post[title]" type="radio" value="Hello World" />',
+ assert_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />',
radio_button("post", "title", "Hello World")
)
- assert_equal('<input id="post_title" name="post[title]" type="radio" value="Goodbye World" />',
+ assert_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />',
radio_button("post", "title", "Goodbye World")
)
end
@@ -166,10 +166,10 @@ def test_auto_index
check_box("post[]", "secret")
)
assert_equal(
-"<input checked=\"checked\" id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />",
+"<input checked=\"checked\" id=\"post_#{pid}_title_hello_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />",
radio_button("post[]", "title", "Hello World")
)
- assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
+ assert_equal("<input id=\"post_#{pid}_title_goodbye_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
radio_button("post[]", "title", "Goodbye World")
)
end

0 comments on commit 98306be

Please sign in to comment.