Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top