aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-05-11 16:36:59 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-05-11 16:36:59 +0000
commitc069f361f090790b9769b349eefa260e57d4c63b (patch)
treeb5d7dd8f4dd84bdbebea10f6b2bed367b3b21f91
parent0a407bca505db3116eb9ff71022022a14300ee47 (diff)
downloadrails-c069f361f090790b9769b349eefa260e57d4c63b.tar.gz
rails-c069f361f090790b9769b349eefa260e57d4c63b.tar.bz2
rails-c069f361f090790b9769b349eefa260e57d4c63b.zip
form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10")
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4334 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb5
-rw-r--r--actionpack/test/template/form_helper_test.rb7
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>',