Skip to content

Commit

Permalink
Custom 'type' attribute support for text_field. [#3646 status:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
stephencelis authored and josevalim committed Jan 14, 2010
1 parent 214b548 commit 2835ec6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/template/form_helper_test.rb
Expand Up @@ -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" />',
Expand Down

1 comment on commit 2835ec6

@dgm
Copy link
Contributor

@dgm dgm commented on 2835ec6 Jun 4, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be back ported to 2.3 as well?

Please sign in to comment.