Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add class attribute to select tag in rails 3

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

like image 827
Mohammad Sadiq Shaikh Avatar asked Aug 16 '12 06:08

Mohammad Sadiq Shaikh


1 Answers

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' } %>
like image 138
Kulbir Saini Avatar answered Sep 20 '22 04:09

Kulbir Saini