maintaining drop down menu selections

i am creating multiple drop down menus using

<%= form.select(:choice, @list.map { | item | [ item[0], item[1] ] }) %>

this works great but when the client hits submit and there are other validation errors it resets the drop down menu.

how do i maintain the selected item.

my search for the options of the slect method has come up empty.

@list is created in the controller and used in the view. can you not test :choice to see if the user has choose an item and then display the drop down with the correct item selected.

thanks.

still not close?

1 <select id="stuff_item_id" name="stuff[item_id]"> 2 <% if @stuff.item_id == 0 or @stuff.item_id == nil -%> 3 <option value="" selected="selected" >Please Selected An Item</

4 <% end -%> 5 <% @items = Item.find(:all, :order => "name") 6 @items.each do |item| %> 7 <option value="<%= item.id %>" 8 <% if @stuff.item_id == item.id -%> selected="selected"<% end -%> 9 > 10 <%= item.name %> (<%= item.description %>) 11 </option> 12 <% end %> 13 </select>

is this the only method to handle a drop down menu. looks like it is comparing the value selected with the item and then setting to selected. this would be a pain if you have a lot of drop down menus in an application.

any suggestions to preserving the item selected by a user. the items of the drop down menu do not come from a simple search, at times they are combined from multiple searches, but basically i have an array, with display item, id# which is passed to the view.