diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 5 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 7 |
3 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 33e2839e69..ef63a8a105 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10"). [Jeremy Kemper] + * Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous] * Small fix in routing to allow dynamic routes (broken after [4242]) [Rick] diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index fd4fe5f12e..286defa54e 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -277,6 +277,11 @@ module ActionView def to_text_area_tag(options = {}) options = DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys) add_default_name_and_id(options) + + if size = options.delete("size") + options["cols"], options["rows"] = size.split("x") + end + content_tag("textarea", html_escape(options.delete('value') || value_before_type_cast(object)), options) end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index a40a1ff662..b0ee744299 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -143,6 +143,13 @@ class FormHelperTest < Test::Unit::TestCase ) end + def test_text_area_with_size_option + assert_dom_equal( + '<textarea cols="183" id="post_body" name="post[body]" rows="820">Back to the hill and over it again!</textarea>', + text_area("post", "body", :size => "183x820") + ) + end + def test_date_selects assert_dom_equal( '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>', |