diff options
author | Stephen Celis <stephen@stephencelis.com> | 2010-01-05 08:32:00 -0600 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-14 01:07:04 +0100 |
commit | 2835ec6134b1e5b706824b568dfaba24672b7409 (patch) | |
tree | 59e6374eea994e65c08132cff7824ba75ff25b4d /actionpack | |
parent | 214b548485f9313639059e8de1ad08611f734fe2 (diff) | |
download | rails-2835ec6134b1e5b706824b568dfaba24672b7409.tar.gz rails-2835ec6134b1e5b706824b568dfaba24672b7409.tar.bz2 rails-2835ec6134b1e5b706824b568dfaba24672b7409.zip |
Custom 'type' attribute support for text_field. [#3646 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index fe060921ff..11ac3ad6f3 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -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) diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 7712883e9c..454b6159ab 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -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" />', |