mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Sanitized the id generated by text_area_tag helper method. text_area_tag('item[description]') should return: <textarea id="item_description" name="item[description]"></textarea> instead of: <textarea id="item[description]" name="item[description]"></textarea> The old id was causing HTML validation failures.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
This commit is contained in:
parent
a14df8c9b2
commit
a94e7d7897
2 changed files with 6 additions and 1 deletions
|
@ -258,7 +258,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.
|
||||
|
|
|
@ -154,6 +154,11 @@ class FormTagHelperTest < ActionView::TestCase
|
|||
assert_dom_equal expected, actual
|
||||
end
|
||||
|
||||
def test_text_area_tag_id_sanitized
|
||||
input_elem = root_elem(text_area_tag("item[][description]"))
|
||||
assert_match VALID_HTML_ID, input_elem['id']
|
||||
end
|
||||
|
||||
def test_text_field_tag
|
||||
actual = text_field_tag "title", "Hello!"
|
||||
expected = %(<input id="title" name="title" type="text" value="Hello!" />)
|
||||
|
|
Loading…
Reference in a new issue