There seems to be just a little documentation on the grouped_select feature in simple_form 2.0 at http://simple-form.plataformatec.com.br/#usage/collections. The documentation offers the line:
f.input :country_id, :collection => @continents, :as => :grouped_select, :group_method => :countries
But that doesn't seem to be giving me enough context to make it work. Here's what I have.
I have three models: Inquiry, Ad, and Insertions
Ads has_many Insertions, and Insertions belongs_to Ads Inquiry belongs_to Insertion, and Insertions has_many Inquiries
This dropdown is for the Inquiry view. Using simple_form I can get = f.input :insertion, :collection => @ads
to at least output a list of the ad titles in the dropdown. I'd like the ad.title to serve as the optgroup. Then I'd like to have the Ads insertions to serve as the selectable content... so something like:
<select>
<optgroup label="Ad.Title">
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
</optgroup>
<optgroup label="Ad.Title">
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
<option value="Ad.Insertion.id">Ad.Insertion.Title</option>
</optgroup>
</select>
Can anyone offer any advise on making this simple_form feature work? I'd really appreciate it!
Please let me know if I can tell you anything else about the app if you have insight on how to execute this property.
Thanks in advance!
UPDATE: I've been able to get something partially working using:
= f.input(:insertion_id, :collection => Ad.order(:name), :as => :grouped_select, :group_method => :insertions)
The problem with this is that there is no way to specify what column is used as the display text from what I can tell. I welcome any input.