Allow radio buttons to work with booleans.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
José Valim 2009-07-24 00:05:57 +02:00 committed by Pratik Naik
parent 1191e3ffaf
commit c34d6279a0
2 changed files with 12 additions and 2 deletions

@ -872,8 +872,8 @@ def radio_button_checked?(value, checked_value)
private
def add_default_name_and_id_for_value(tag_value, options)
if tag_value
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
unless tag_value.nil?
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
specified_id = options["id"]
add_default_name_and_id(options)
options["id"] += "_#{pretty_tag_value}" unless specified_id

@ -307,6 +307,16 @@ def test_radio_button_respects_passed_in_id
)
end
def test_radio_button_with_booleans
assert_dom_equal('<input id="post_secret_true" name="post[secret]" type="radio" value="true" />',
radio_button("post", "secret", true)
)
assert_dom_equal('<input id="post_secret_false" name="post[secret]" type="radio" value="false" />',
radio_button("post", "secret", false)
)
end
def test_text_area
assert_dom_equal(
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>',