Jacob
Jacob

Reputation: 6487

How to use grouped_collection_select to show multiple selection?

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?

Upvotes: 7

Views: 2139

Answers (2)

Manivannan Jeganathan
Manivannan Jeganathan

Reputation: 513

try

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

Upvotes: 5

BvuRVKyUVlViVIc7
BvuRVKyUVlViVIc7

Reputation: 11811

Maybe with

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

not tested!

Upvotes: 0

Related Questions