Skip to content

Commit

Permalink
Fixed that radio_button_tag should generate unique ids (closes #3353)…
Browse files Browse the repository at this point in the history
… [BobSilva/rebecca/josh]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jun 23, 2007
1 parent 46b0e7d commit 62a9203
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Fixed that radio_button_tag should generate unique ids #3353 [BobSilva/rebecca/josh]

* Fixed that HTTP authentication should work if the header is called REDIRECT_X_HTTP_AUTHORIZATION as well #6754 [mislaw]

* Don't mistakenly interpret the request uri as the query string. #8731 [lifofifo, Jeremy Kemper]
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_view/helpers/form_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def check_box_tag(name, value = "1", checked = false, options = {})
# Creates a radio button.
def radio_button_tag(name, value, checked = false, options = {})
pretty_tag_value = value.to_s.gsub(/\s/, "_").gsub(/(?!-)\W/, "").downcase
html_options = { "type" => "radio", "name" => name, "id" => "#{name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys)
pretty_name = name.gsub(/\[/, "_").gsub(/\]/, "")
html_options = { "type" => "radio", "name" => name, "id" => "#{pretty_name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked
tag :input, html_options
end
Expand Down
3 changes: 3 additions & 0 deletions actionpack/test/template/form_tag_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def test_radio_button_tag
expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />)
assert_dom_equal expected, actual

actual = radio_button_tag("person[gender]", "m")
expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />)
assert_dom_equal expected, actual
end

def test_select_tag
Expand Down

0 comments on commit 62a9203

Please sign in to comment.