Frage

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?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top