Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

form.text_area handles the :size option just like the original text_a…

…rea (:size => '60x10' becomes cols="60" rows="10")

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4334 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c069f361f090790b9769b349eefa260e57d4c63b 1 parent 0a407bc
@jeremy jeremy authored
View
2  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]
View
5 actionpack/lib/action_view/helpers/form_helper.rb
@@ -277,6 +277,11 @@ def to_radio_button_tag(tag_value, options = {})
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
View
7 actionpack/test/template/form_helper_test.rb
@@ -143,6 +143,13 @@ def test_text_area_with_alternate_value
)
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>',
Please sign in to comment.
Something went wrong with that request. Please try again.