Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert placeholder text in text_area_tag in rails?

I'm using the following code to generate a textarea tag:

<%= text_area_tag :comment, '', autocomplete: "off", class: "form-control", placeholder: "Your Comment" %>

When rendered, it produces the following HTML:

<textarea name="comment" id="comment" autocomplete="off" class="form-control" placeholder="Your Comment"></textarea>

I know that if there is some text between <textarea> and </textarea>, the placeholder won't show up, but in my case, there is nothing in-between, as it is clear from rendered HTML. So how can I put a placeholder text for textarea?

like image 880
Arslan Ali Avatar asked Oct 14 '25 14:10

Arslan Ali


1 Answers

The html seems to be valid to me.

<textarea name="comment" autocomplete="off" class="test" id="moretest" data-value="moretest" placeholder="snowman or iceman?"></textarea>
like image 52
Persijn Avatar answered Oct 17 '25 05:10

Persijn