开发者

Rails collection_select prompt appears on initial page load, not thereafter. Any fix?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜