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
This commit is contained in:
Jeremy Kemper
2006-05-11 16:36:59 +00:00
parent 0a407bca50
commit c069f361f0
3 changed files with 14 additions and 0 deletions

View File

@@ -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 File

@@ -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

View File

@@ -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>',