I''m trying to get a blank date as the default when using the select_date helper as follows: select_date Date.today, :prefix => ''startdate'', :order => [:month, :day, :year], :include_blank => true This gives me the current date as the default. It is my understanding (or misunderstanding) that adding the :include_blank => true will default the values to blanks. But it doesn''t seem to be doing that. Although including this option does allow me to select a blank value. Just not defaulting to blanks, which is what I''m trying to accomplish. Thanks in advance for any help. Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Instead of Date.today, pass in nil. As long as :include_blank = true option is present, the default date will be blank. 2008/7/9 stevel <isignin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > I''m trying to get a blank date as the default when using the > select_date helper as follows: > > select_date Date.today, :prefix => ''startdate'', :order => > [:month, :day, :year], :include_blank => true > > This gives me the current date as the default. It is my understanding > (or misunderstanding) that adding the :include_blank => true will > default the values to blanks. But it doesn''t seem to be doing that. > Although including this option does allow me to select a blank value. > Just not defaulting to blanks, which is what I''m trying to accomplish. > > Thanks in advance for any help. > > Steve > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I was thinking I had to put a nil there but didn''t managed to figure out how to do it. I was using a plain "" which didn''t work obviously. I didn''t think of just using the nil variable. Anyhow it worked. Thank you so much. On Jul 8, 2:38 pm, "Phil Calder" <philcal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Instead of Date.today, pass in nil. As long as :include_blank = true option > is present, the default date will be blank. > > 2008/7/9 stevel <isig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > I''m trying to get a blank date as the default when using the > > select_date helper as follows: > > > select_date Date.today, :prefix => ''startdate'', :order => > > [:month, :day, :year], :include_blank => true > > > This gives me the current date as the default. It is my understanding > > (or misunderstanding) that adding the :include_blank => true will > > default the values to blanks. But it doesn''t seem to be doing that. > > Although including this option does allow me to select a blank value. > > Just not defaulting to blanks, which is what I''m trying to accomplish. > > > Thanks in advance for any help. > > > Steve--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
FWIW--this is working for me: f.date_select :start_date, :include_blank => true, :order => [:day, :month, :year] Not sure if the difference is the order of the args, or the fact that I''m calling date_select vs. your select_date. (What''s the difference between those 2 helpers?) HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of stevel Sent: Tuesday, July 08, 2008 2:21 PM To: Ruby on Rails: Talk Subject: [Rails] How to get a default blank for select_date? I''m trying to get a blank date as the default when using the select_date helper as follows: select_date Date.today, :prefix => ''startdate'', :order => [:month, :day, :year], :include_blank => true This gives me the current date as the default. It is my understanding (or misunderstanding) that adding the :include_blank => true will default the values to blanks. But it doesn''t seem to be doing that. Although including this option does allow me to select a blank value. Just not defaulting to blanks, which is what I''m trying to accomplish. Thanks in advance for any help. Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I believe date_select requires that you specify an object and the
method as in:
date_select(object_name, method, options={})
whereas select_date only needs a variable such as:
select_date( variable, option={})
when you use f.date_select you have already defined the object
beforehand, ( Example: <% form_for @object do |f| ), and hence
your :start_date is the method for your object f. You get the blank
result because your :start_date is presumably nil in the beginning.
Not sure of that answers your question or make it more confusing. :-)
Steve
On Jul 8, 5:25 pm, "Pardee, Roy"
<parde...-go57ItdSaco@public.gmane.org> wrote:> FWIW--this is working for me:
>
> f.date_select :start_date, :include_blank => true, :order => [:day,
> :month, :year]
>
> Not sure if the difference is the order of the args, or the fact that
> I''m calling date_select vs. your select_date. (What''s
the difference
> between those 2 helpers?)
>
> HTH,
>
> -Roy
>
> -----Original Message-----
> From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>
> [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf
Of stevel
> Sent: Tuesday, July 08, 2008 2:21 PM
> To: Ruby on Rails: Talk
> Subject: [Rails] How to get a default blank for select_date?
>
> I''m trying to get a blank date as the default when using the
select_date
> helper as follows:
>
> select_date Date.today, :prefix => ''startdate'', :order
=> [:month, :day,
> :year], :include_blank => true
>
> This gives me the current date as the default. It is my understanding
> (or misunderstanding) that adding the :include_blank => true will
> default the values to blanks. But it doesn''t seem to be doing
that.
> Although including this option does allow me to select a blank value.
> Just not defaulting to blanks, which is what I''m trying to
accomplish.
>
> Thanks in advance for any help.
>
> Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---