adding a class to a text_field_tag
36,656
Solution 1
You declared it wrong. Here is the one will work.
<%= text_field_tag :login_aei, "", class: 'form-control' %>
I gave the value of the input
field as empty string, but you can give any value what meets your business needs.
Solution 2
In the case of data binding is needed,
<%= text_field_tag(:personName,"#{@person.name}", class:'form-control', placeholder: 'User Name' )%>
Author by
David Geismar
I started web development 3 months ago. I wish to become a rails ninja. Yahuuuu
Updated on October 22, 2020Comments
-
David Geismar over 3 years
I am trying to give a class to my text_field_tag
I have this
<%= text_field_tag :login_aei, class: 'form-control' %>
but it keeps generating this :
<input type="text" name="login_aei" id="login_aei" value="{:class=>"form-control"}">
What am I doing wrong ?
-
Yesha almost 6 yearsWorks prefectly