Reputation: 41874
I am working on a simple private messaging application and, when replying to a message, I would like to display the original message a few spaces down in the text area. Here is what I am putting:
<%= f.input :content, :as=>:text, :label => "Reply", :input_html => { :value=> "<br /><br />Original Message: #{@message.content}".html_safe } %>
and.. here is what I'm seeing:
Upvotes: 3
Views: 2067
Reputation: 72514
The problem is that the HTML standard does not allow textarea
elements to have any nested elements, only plain text is allowed.
To work around this you have to use normal line breaks via \n
. (See this existing SO question)
Upvotes: 2
Reputation: 15788
Try this one:
<%= f.input :content, :as=>:text, :label => "Reply", :input_html => { :value=> ("<br /><br />" +"Original Message: #{@message.content}".html_safe) } %>
Upvotes: 1
Reputation: 26861
try with \n
instead of <br/>
, and also, apply html_safe
only to @message.content
, not to the whole string:
<%= f.input :content, :as=>:text, :label => "Reply", :input_html => { :value=> "\n\nOriginal Message: " + @message.content.html_safe } %>
Upvotes: 2