I'm using collection_select to populate a drop-down menu with items from a database. That part is working fine. I'd like to add an option for "all" in the drop-down menu in case the user wants to see data for all the stores - how can I do this? Thanks
on 2007-02-15 15:01
on 2007-02-15 17:01
you can pass :include_blank => true as an option which adds a blank option as the first option, but i don't think there is a way to set the text or value of the blank option. collection_select(:model, :id, @models, "id", "name", :include_blank => true)
on 2007-02-15 17:09
after looking at the source, there is a way... use the :prompt => "All" option in place of the :include_blank option and you will get an initial option with the text set to what you pass and the value will be empty collection_select(:model, :id, @models, "id", "name", :prompt => "All") then just check for a blank value being submitted.
on 2007-02-16 13:23
Works like a charm - thank you!