Alex Rivera | Logout

RoR set value for textarea

Asked 2010-08-26T22:34:25.130
21

Is there a way to specify a value to the text_area method that will be placed between the generated textarea tags?

This is an example of the code I am using.

<% remote_form_for ... do |f| %>
      <%= f.text_area :message %>
      <%= f.submit 'Update' %>
<% end %>
Edit
Report

1 Answer

4

The FormHelper text_area method takes a second argument to specify the method which returns the body of a textarea.

From the documentation linked above:

  text_area(:post, :body, :cols => 20, :rows => 40)
  # => <textarea cols="20" rows="40" id="post_body" name="post[body]">
  #      #{@post.body}
  #    </textarea>

  text_area(:comment, :text, :size => "20x30")
  # => <textarea cols="20" rows="30" id="comment_text" name="comment[text]">
  #      #{@comment.text}
  #    </textarea>

  text_area(:application, :notes, :cols => 40, :rows => 15, :class => 'app_input')
  # => <textarea cols="40" rows="15" id="application_notes" name="application[notes]" class="app_input">
  #      #{@application.notes}
  #    </textarea>

  text_area(:entry, :body, :size => "20x20", :disabled => 'disabled')
  # => <textarea cols="20" rows="20" id="entry_body" name="entry[body]" disabled="disabled">
  #      #{@entry.body}
  #    </textarea>
answered 2010-08-26T22:39:07.543

Your Answer