From ea657f5e64a1ad8d39cb7b6849f4091bddba0a8f Mon Sep 17 00:00:00 2001 From: Dennis Krupenik Date: Wed, 15 Apr 2009 02:01:59 +0300 Subject: [PATCH] added missing sanitize_to_id to FormTagHelper#text_area_tag --- .../lib/action_view/helpers/form_tag_helper.rb | 3 +-- actionpack/test/template/form_tag_helper_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 6d39a53..6ba915f 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -257,7 +257,7 @@ module ActionView options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split) end - content_tag :textarea, content, { "name" => name, "id" => name }.update(options.stringify_keys) + content_tag :textarea, content, { "name" => name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) end # Creates a check box form input tag. @@ -475,7 +475,6 @@ module ActionView def sanitize_to_id(name) name.to_s.gsub(']','').gsub(/[^-a-zA-Z0-9:.]/, "_") end - end end end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index c713b8d..aee41aa 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -206,6 +206,11 @@ class FormTagHelperTest < ActionView::TestCase assert_match VALID_HTML_ID, input_elem['id'] end + def test_text_area_tag_id_sanitized + text_area_elem = root_elem(text_area_tag("item[][title]")) + assert_match VALID_HTML_ID, text_area_elem['id'] + end + def test_label_tag_without_text actual = label_tag "title" expected = %() -- 1.6.2.2