# Using multiple select form

**URL:** <https://www.ruby-forum.com/t/using-multiple-select-form/112141>\
**Category:** Rails\
**Created:** [August 15, 2007, 9:29pm UTC](https://www.ruby-forum.com/t/using-multiple-select-form/112141 "2007-08-15T21:29:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![d2kagw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@d2kagw](https://www.ruby-forum.com/u/d2kagw)\
**Post date:** [August 15, 2007, 9:29pm UTC](https://www.ruby-forum.com/t/using-multiple-select-form/112141/1 "2007-08-15T21:29:31Z")

</div>

I think this is a simple problem but I haven’t had any luck so far.

Here are the models involved:

Product has\_and\_belongs\_to\_many SubCategories  
SubCategory belongs\_to Category / has\_and\_belongs\_to\_many Products  
Category has\_many SubCategories

So when creating a new Product I have a multiple select form of  
SubCategories grouped by the Categories they belong to. I use  
option\_groups\_from\_collection\_for\_select to create the optgroups /  
options.

When this form is submitted, the only parameter from this form is the  
first one selected:

“sub\_category”=\>{“id”=\>“3”} or whatever is all that shows up.

Here is the view:  
[select multiple=“multiple” name=“sub\_category[id]”  
id=“sub\_category[id]”]  
[%=  
option\_groups\_from\_collection\_for\_select(@categories, :sub\_categories,  
:name, :id, :name)  
%]  
[/select]

(new to the mailing list, dunno if it eats html )

Thanks,

-Aaron
