Fixed that FormHelper#radio_button would produce invalid ids (closes #11298) [harlancrystal]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9088 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2008-03-24 21:32:50 +00:00
parent 123f5a357d
commit b0bfcca16e
3 changed files with 7 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* Fixed that FormHelper#radio_button would produce invalid ids #11298 [harlancrystal]
* Added :confirm option to submit_tag #11415 [miloops]
* Fixed NumberHelper#number_with_precision to properly round in a way that works equally on Mac, Windows, Linux (closes #11409, #8275, #10090, #8027) [zhangyuanyi]

View File

@@ -498,8 +498,8 @@ module ActionView
options["checked"] = "checked" if checked
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
options["id"] ||= defined?(@auto_index) ?
"#{@object_name}_#{@auto_index}_#{@method_name}_#{pretty_tag_value}" :
"#{@object_name}_#{@method_name}_#{pretty_tag_value}"
"#{tag_id_with_index(@auto_index)}_#{pretty_tag_value}" :
"#{tag_id}_#{pretty_tag_value}"
add_default_name_and_id(options)
tag("input", options)
end

View File

@@ -187,6 +187,9 @@ class FormHelperTest < Test::Unit::TestCase
assert_dom_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />',
radio_button("post", "title", "Goodbye World")
)
assert_dom_equal('<input id="item_subobject_title_inside_world" name="item[subobject][title]" type="radio" value="inside world"/>',
radio_button("item[subobject]", "title", "inside world")
)
end
def test_radio_button_is_checked_with_integers