Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want a date select box with blank values selected by default

I used the following date_select helpers but none of them shows a date select box with blank values selected by default. With all the following code, I get the select box but with the current date selected. I'm on Rails 2.3.2

<%= f.date_select :featured_at, :default => {:day => nil, :month => nil, :year => nil} %>
<%#= date_select("post", "featured_at", :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' }) %>
<%#= date_select("post", "featured_at", :default => { :day => nil }) %>
<%#= f.date_select :featured_at, :include_blank => true, :order => [:day, :month, :year] %>
like image 336
Autodidact Avatar asked Sep 14 '09 20:09

Autodidact


2 Answers

Far easier to do this:

<%= f.date_select :featured_at, {:include_blank => true, :default => nil} %>
like image 119
Eric Avatar answered Mar 08 '23 19:03

Eric


 <%= f.label :expired %><br />
    <%= f.datetime_select :expired,:prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' }  %>

works for me

like image 43
philipth Avatar answered Mar 08 '23 20:03

philipth