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:
parent
214b548485
commit
2835ec6134
2 changed files with 6 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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" />',
|
||||
|
|
Loading…
Reference in a new issue