Reputation: 6475
I want to create a nested multi select in formtastic from two objects like this -
Option 1
Option A
Option B
Option C
Option 2
Option A
Option B
Option C
list1 = ['option1', 'option2']
list2 = ['Option A', 'Option B', 'Option C']
Is this possible with formtastic or is it better to use a helper to format the data ?
Thanks, Alex
Upvotes: 0
Views: 599
Reputation: 9226
It's possible, you have to use something like:
<%= f.input :input_field_name, :as => :select, :collection => grouped_options_for_select(['List 1', list1], ['List 2', list2]) %>
Look up the Formtastic documentation for input_select
and the Rails API for grouped_options_for_select
for other possible formatting options.
Upvotes: 1