aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-03-24 21:32:50 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-03-24 21:32:50 +0000
commitb0bfcca16efff329e0cfaebc18a7debed126473b (patch)
treea0926c4f73c773214ab21e87ceb310e919b76b89 /actionpack
parent123f5a357dc176225d57dc78e773338642048120 (diff)
downloadrails-b0bfcca16efff329e0cfaebc18a7debed126473b.tar.gz
rails-b0bfcca16efff329e0cfaebc18a7debed126473b.tar.bz2
rails-b0bfcca16efff329e0cfaebc18a7debed126473b.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionpack/test/template/form_helper_test.rb3
3 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index d2396a70f9..303ef75977 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -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]
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index cc3c09d50c..22c6562cc7 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -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
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index b788a9e2f9..766e88375b 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -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