Reputation: 1099
I want to set a default text_area value.
<%= f.text_area :observations, :value => partner_setting.observations, :class => "tinymce", :rows => 4, :cols => 120 %>
But the field displays the same default text after replacing the content and returning to edit. How can I reset it after create?
Thanks!
Upvotes: 3
Views: 4319
Reputation: 1953
If you want the text to persist on focus, try this instead:
<%= f.input :message, input_html: { value: 'hello hello'} %>
Upvotes: 2
Reputation: 1099
thanks for suggestions, I solved this issue through a helper method which takes 2 params (passing them from the view):
def offer_settings offer, key
offer.send(key) || offer.partner_setting.send(key)
end
view:
<%= f.text_area :offer_greeting, :value => offer_settings(@offer, :offer_greeting), :class => "tinymce", :rows => 4, :cols => 120 %>
Upvotes: 0
Reputation: 5458
You will need a placeholder, otherwise it will erase your content.
<%= f.text_area :observations, :placeholder => partner_setting.observations, :class => "tinymce", :rows => 4, :cols => 120 %>
Upvotes: 0