I want to add class attribute to select tag in rails 3 my code is
<div >
<%= f.label :type %><br />
<%= f.select "type_id", options_from_collection_for_select(@type,
"type_id","name"),:include_blank=>true%>
</div>
My problem is that I want to add one specific class name to this select tag for validation purpose. I tried adding
:class=>"myclassname"
but it not worked for me.plz resolve my issue
You can add class attribute like this. Check select
<%= f.select "type_id",
options_from_collection_for_select(@type, "type_id","name"),
{ :include_blank => true },
{ :class => 'myclassname' } %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.