Domanda

I am trying to add a class to the select form helper, here is my code:

<%= f.select :manager_id, user.collect {|u| [u.username, u.id]}, :prompt => "Select manager 
username", :class => "btn btn-default dropdown-toggle" %>

But it didn't work, and is there an option to add multiple selection?

È stato utile?

Soluzione

Add the curly brackets for the hash. class is part of the last parameter. If you don't add the brackets, it goes as third

<%= f.select :manager_id, user.collect {|u| [u.username, u.id]}, {:prompt => "Select manager 
username"}, {:class => "btn btn-default dropdown-toggle", :multiple => true} %>

I haven't tried the multiple option in select. But it should work according to this post

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top