jeudi 9 février 2017

Ruby on Rails: Text field with default value containing html tags

In my RoR application, I have a form that contains a CKEditor text area so that a user can add their own styling to the text. What I want to do is add html formatted text to the text area so that this displays when a user goes to the form - so the text area will have formatted text as its default value.

Is this possible?

I have tried to do the following:

<%= f.cktext_area :message, rows: 10, value: "<bold>test</bold>" %>

<%= f.cktext_area :message, rows: 10, value: "<bold>test</bold>".html_safe %>

<%= f.cktext_area :message, rows: 10, value: ("<bold>test</bold>").html_safe %>

But none of these work. This is a seemingly simple task, but I cannot figure it out.

I have looked at the below links but they do not seem to address this same issue.

Text Field Tag Placeholder Returning As Value

In Rails, how can I allow some html in a text area?

How do I show formatted text in rails text area?

Aucun commentaire:

Enregistrer un commentaire