mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed that radio_button_tag should generate unique ids (closes #3353) [BobSilva/rebecca/josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
46b0e7d1d7
commit
62a9203a5e
3 changed files with 7 additions and 1 deletions
|
@ -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]
|
||||
|
|
|
@ -122,7 +122,8 @@ module ActionView
|
|||
# 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
|
||||
|
|
|
@ -93,6 +93,9 @@ class FormTagHelperTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue