stevel | 8 Jul 23:20

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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Phil Calder | 8 Jul 23:38

Re: How to get a default blank for select_date?

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
-~----------~----~----~----~------~----~------~--~---

stevel | 9 Jul 00:00

Re: How to get a default blank for select_date?


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...@...> 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...@...>:
>
>
>
> > 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Pardee, Roy | 9 Jul 02:25

Re: How to get a default blank for select_date?


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@...
[mailto:rubyonrails-talk@...] 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

stevel | 9 Jul 02:44

Re: How to get a default blank for select_date?


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...@...> 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@...
>
> [mailto:rubyonrails-talk@...] 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane