diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-10-15 14:18:51 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-10-15 14:18:51 -0300 |
commit | 448928f6396af9ac70dfe8a197f60166aadf7a43 (patch) | |
tree | 651db02244946391042c213ae2a39764d2065d72 | |
parent | c86957b884f50013696dd614c78f5e5275d5ecd7 (diff) | |
parent | dee00df11c34c43de65d36288f211a5229987ab2 (diff) | |
download | rails-448928f6396af9ac70dfe8a197f60166aadf7a43.tar.gz rails-448928f6396af9ac70dfe8a197f60166aadf7a43.tar.bz2 rails-448928f6396af9ac70dfe8a197f60166aadf7a43.zip |
Merge pull request #17273 from claudiob/fix-file-and-password-field-tag
Fix how file_ and password_field_tag edit options
-rw-r--r-- | actionview/lib/action_view/helpers/form_tag_helper.rb | 4 | ||||
-rw-r--r-- | actionview/test/template/form_tag_helper_test.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index b79d66ce6e..69893b8abd 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -263,7 +263,7 @@ module ActionView # file_field_tag 'file', accept: 'text/html', class: 'upload', value: 'index.html' # # => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" /> def file_field_tag(name, options = {}) - text_field_tag(name, nil, options.update("type" => "file")) + text_field_tag(name, nil, options.merge(type: :file)) end # Creates a password field, a masked text field that will hide the users input behind a mask character. @@ -296,7 +296,7 @@ module ActionView # password_field_tag 'pin', '1234', maxlength: 4, size: 6, class: "pin_input" # # => <input class="pin_input" id="pin" maxlength="4" name="pin" size="6" type="password" value="1234" /> def password_field_tag(name = "password", value = nil, options = {}) - text_field_tag(name, value, options.update("type" => "password")) + text_field_tag(name, value, options.merge(type: :password)) end # Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions. diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 771e3fefc3..2d89332841 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -170,6 +170,13 @@ class FormTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end + def test_multiple_field_tags_with_same_options + options = {class: 'important'} + assert_dom_equal %(<input name="title" type="file" id="title" class="important"/>), file_field_tag("title", options) + assert_dom_equal %(<input type="password" name="title" id="title" value="Hello!" class="important" />), password_field_tag("title", "Hello!", options) + assert_dom_equal %(<input type="text" name="title" id="title" value="Hello!" class="important" />), text_field_tag("title", "Hello!", options) + end + def test_radio_button_tag actual = radio_button_tag "people", "david" expected = %(<input id="people_david" name="people" type="radio" value="david" />) |