Is there any way to use the: selected parameter, which you would use in a regular select view helper with the grouped_collection_select function? I would like to set a value to be preselected in my list. I tried the transition: selected as an option with no luck!
Here are some snippts of my test code:
grouped_collection_select 'user[subscription_attributes]', :subscription_plan_id, Trade.order(:name).all, :subscription_plans, :name, :id, :display_name, { :include_blank => true, :selected => 5 }
grouped_collection_select 'user[subscription_attributes]', :subscription_plan_id, Trade.order(:name).all, :subscription_plans, :name, :id, :display_name, :include_blank => true, :selected => 5
None of the versions work. Selected not selected. I use this to set the value for a nested model. I use railscasts dynamic selection methods: http://railscasts.com/episodes/88-dynamic-select-menus-revised
I could not get formtastic to play well with the group, so I had to do it manually, but I do not save this value when the user fails. I would like to keep this set when they fix validation errors.
source
share