aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-05-24 20:47:03 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-05-24 20:47:03 +0000
commit74d1512b99e17c25de5ed42eb844374969847619 (patch)
tree302b57003c5f1993bdf0ac679a6e1255e76c891a /actionpack
parentb290bc6b2f3ddefdfecd58d60bfa2517612dbad4 (diff)
downloadrails-74d1512b99e17c25de5ed42eb844374969847619.tar.gz
rails-74d1512b99e17c25de5ed42eb844374969847619.tar.bz2
rails-74d1512b99e17c25de5ed42eb844374969847619.zip
Added option to suppress :size when using :maxlength for FormTagHelper#text_field #3112 [rails@tpope.info]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6830 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb6
3 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index cba7c56d38..252e7c0ecf 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added option to suppress :size when using :maxlength for FormTagHelper#text_field #3112 [rails@tpope.info]
+
* catch possible WSOD when trying to render a missing partial. Closes #8454 [Catfish]
* Rewind request body after reading it, if possible. #8438 [s450r1]
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index c985a22edb..7325aad398 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -393,7 +393,7 @@ module ActionView
def to_input_field_tag(field_type, options = {})
options = options.stringify_keys
- options["size"] ||= options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"]
+ options["size"] = options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"] unless options.key?("size")
options = DEFAULT_FIELD_OPTIONS.merge(options)
if field_type == "hidden"
options.delete("size")
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 0ee8c41d1b..134416c03b 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -86,6 +86,12 @@ class FormHelperTest < Test::Unit::TestCase
assert_dom_equal expected, text_field("post", "title", :maxlength => 35)
end
+ def test_text_field_removing_size
+ expected = '<input id="post_title" maxlength="35" name="post[title]" type="text" value="Hello World" />'
+ assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil)
+ assert_dom_equal expected, text_field("post", "title", :maxlength => 35, :size => nil)
+ end
+
def test_text_field_doesnt_change_param_values
object_name = 'post[]'
expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />'