Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 2835ec6134b1e5b706824b568dfaba24672b7409 1 parent 214b548
@stephencelis stephencelis authored josevalim committed
View
2  actionpack/lib/action_view/helpers/form_helper.rb
@@ -798,7 +798,7 @@ def to_input_field_tag(field_type, options = {})
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
5 actionpack/test/template/form_helper_test.rb
@@ -201,6 +201,11 @@ def test_text_field_with_options
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" />',

1 comment on commit 2835ec6

@dgm

Can this be back ported to 2.3 as well?

Please sign in to comment.
Something went wrong with that request. Please try again.