Ben Sinclair
2005-Dec-19 17:34 UTC
Pre-selecting options_from_collection_for_select Options
I''m trying to use options_from_collection_for_select to generate options for a multiple select: <select id="metro_area_states" name="states[]" size="10" multiple="multiple"> <%= options_from_collection_for_select State.find(:all), :id, :name, @metro_area.states %> </select> When selecting values for the first time, it works great. I use @metro_area.state_ids= in the controller to set the selected states, and it saves just fine. When editing, it should pre-select the states using @metro_area.states, but it doesn''t. The docs for options_from_collection_for_select say it uses the value parameter, :id in my case, to match against the collection. I know @metro_area.states contains State objects. I can output them just fine manually, but options_from_collection_for_select doesn''t like them. Should I just do this manually myself, or is there a way to make this work? -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- Unable to get selected option with options_from_collection_for_select
- Problem with select, options_from_collection_for_select for selected items
- selected value for options_from_collection_for_select
- options_from_collection_for_select & multiple columns
- options_from_collection_for_select