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 %>
<% remote_form_for ... do |f| %>
<%= f.text_area :message, :value => "my default value" %>
<%= f.submit 'Update' %>
<% end %>
You should be using the 'placeholder' HTML attribute for showing default texts in HTML fields. Thats the whole purpose of this attribute. The way to use it in ROR is:-
<%= f.text_area :message, :placeholder => "my default value" %>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With