1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Custom 'type' attribute support for text_field. [#3646 status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Stephen Celis 2010-01-05 08:32:00 -06:00 committed by José Valim
parent 214b548485
commit 2835ec6134
2 changed files with 6 additions and 1 deletions

View file

@ -798,7 +798,7 @@ module ActionView
if field_type == "hidden"
options.delete("size")
end
options["type"] = field_type
options["type"] ||= field_type
options["value"] ||= value_before_type_cast(object) unless field_type == "file"
options["value"] &&= html_escape(options["value"])
add_default_name_and_id(options)

View file

@ -201,6 +201,11 @@ class FormHelperTest < ActionView::TestCase
hidden_field("post", "title", :value => "Something Else")
end
def test_text_field_with_custom_type
assert_dom_equal '<input id="user_email" size="30" name="user[email]" type="email" />',
text_field("user", "email", :type => "email")
end
def test_check_box
assert_dom_equal(
'<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',