如何使用grouped_collection_select显示多个选择?

时间:2022-01-27 15:57:37

I'm using the following code to display a tree view selection box of categories:

我正在使用以下代码显示类别的树视图选择框:

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 have it display checkboxes instead of a select box?

此外,它是否可以显示复选框而不是选择框?

2 个解决方案

#1


5  

try

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

#2


0  

Maybe with

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

not tested!

#1


5  

try

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

#2


0  

Maybe with

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

not tested!