Rails 2.3.11.
I have a search form like this...
- form_for(@search) do |form|
# bla bla bla
= form.collection_select(:Location_eq,
Contract.all_locations, :first, :last,
{:prompt => '-- Select --'},
{:class => '开发者_运维技巧ff'})
When the page loads, the first option labeled "-- Select --" (and having value=''
) appears as expected.
I select an option from that menu and submit the form. The page reloads with the search results. The "-- Select --" option is no longer present in the menu.
This is a problem because the user may want to clear that menu -- take it back to just "-- Select --".
Any way to get the prompt to to survive a form submission?
(I'm using Haml, not Erb, but you get the idea.)
:prompt
is behaving as intended. What you're trying to do is :include_blank
.
精彩评论