ActionView::Helpers::FormHelper

Alias: text_area

def textarea(object_name, method, options = {})

Description

Creates a <textarea> for a model attribute.

Arguments

Changing a value updates the ERB and HTML.

object_name:article
method:summary
options= {}
"40x5"
A "COLSxROWS" string is split into cols and rows. Without an x, as in "40", only cols is added. Anything other than a string (such as a number) adds nothing. Overrides the :cols and :rows options.
"Hello"
Used as the content of the <textarea>, not as the value attribute. Defaults to the object's value.
Common options

Rails handles these the same way in every helper. textarea is not a …_field, so it does not build a size attribute from the :maxlength option, and maxlength becomes an HTML attribute as is. Options the HTML spec does not allow on <textarea> are left out here.

Shared with …_field helpers and others

true sets placeholder to the first of the following that is found:
  1. The helpers.placeholder.article.summary translation
  2. If there is an object, the activerecord.attributes.article.summary translation (what human_attribute_name returns)
  3. The attribute name run through humanize (Summary)
A symbol (such as :home) looks for a translation specific to that value, in this order:
  1. The helpers.placeholder.article.summary.home translation
  2. If there is an object, the activerecord.attributes."article/summary".home translation
  3. The result of humanize (Home with an object, Summary without)
A string is used as is. false does not look up a translation and gives placeholder="false".

Shared by form helpers

"q"
Replaces the generated name with the given value. nil omits name.
nil
Replaces the generated id with the given value. nil omits id.

Shared by all helpers

true adds disabled="disabled"; false omits it. The same goes for every HTML attribute in Rails' list (BOOLEAN_ATTRIBUTES), such as readonly, required and autofocus: any value other than false or nil adds it as attr="attr".
{active: true, hidden: false}
A hash gives the keys whose values are not false or nil, joined with spaces. An array gives its elements joined with spaces, after removing nil, false and empty strings (including whitespace-only strings).
{controller: "tags", tags_suggestions_value: ["ruby", "rails"]}
A hash adds data-* attributes, with _ in the keys converted to -. Array and hash values are converted to JSON strings.
{describedby: ["name_help", "name_error"], invalid: false}
Like :data, adds aria-* attributes. Array values are joined with spaces, leaving out nil and empty strings (nothing is added if none remain). For a hash value, the keys whose values are not false or nil are joined with spaces.
["section-user", "name"]
An array sets autocomplete to its elements joined with spaces.
Any other options become HTML attributes of the <textarea>; those with a nil value are left out.

ERB

Changes from the previous output: Added Removed Changed


          

HTML


          

Preview

Interacting with the preview updates the form submission.

Form submission

Form data

namevalue
Request body

Content-Type:


              

params