How to use grouped_collection_select to display multiple choices?

I use the following code to display a selection tree for the category tree:

grouped_collection_select(:categories, :category_id, Category.top_level, :children, :name, :id, :name, :include_blank => true) 

How can I change it to allow multiple selection?

Also, is it possible to display checkboxes instead of a select box?

+7
source share
2 answers

to try

 grouped_collection_select(:categories, :category_id, Category.top_level, :children, :name, :id, :name, {:include_blank => true}, { :multiple => true } 
+5
source

Maybe with

 grouped_collection_select(:categories, :category_id, Category.top_level, :children, :name, :id, :name, :include_blank => true, { :multiple => true } 

not tested!

0
source

All Articles