RE: [PEAR] HTML_QuickForm_Date display before 1969
| From: | Joseph Blythe | Date: | Tue, 18 Jan 2005 07:21:31 +0000 |
| Subject: | RE: [PEAR] HTML_QuickForm_Date display before 1969 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16985@lists.php.net to get a copy of this message | ||
Hi,
We ran into simular troubles when retrieving mySQL timestamps and trying to
use HTML_QuickForm::setDefaults the default date element is a group so
instead of doing:
$qf->setDefaults('date'=>'1940-02-13');
format it as an array like (you will need to convert the timestamp first)
$qf->setDefaults('date'=> array('Y'=>'1940',
'M'=>'02', 'd'=>'13'));
Regards,
Huy and Joseph (hehe took two of us to work that out)
-----Original Message-----
From: Sarah Gray [mailto:sarah@fabled.net]
Sent: Tuesday, 18 January 2005 3:16 PM
To: Pear
Subject: Re: [PEAR] HTML_QuickForm_Date display before 1969
Actually, am I just running into this issue because PHP date functions are
only
guaranteed to work after Jan 1, 1970? And so regardless of where I use them,
like
in my HTML_QuickForm_Date elements, I can't get an earlier date? This didn't
strike me as obvious until a few minutes ago when I was thinking about the
limits
of PHP date, and then I thought 'of course! This is probably the reason my
dropdowns balk when going earlier than 1969 (12-31), and I was looking for
something more complex that had to do with FormBuilder'.
If I'm right here, to generate date dropdowns for dates prior to 1970 (ie,
birthdays of older people), is there anything you'd recommend other than
creating
individual elements in a group in the form and building a date element
manually?
Thanks,
Sarah
Sarah Gray wrote:
> Hi,
>
> >
> > You shouldn't have to do this. Put this element in
> > $this->fb_preDefElement['DOB'] in preGenerateForm instead of removing
> > and recreating in postGenerateForm. This will also remove the need for
> > the setValue call below, which could easily break as FB uses
> > setDefaults. Try this and see if the problem is fixed.
>
> Thanks for the suggestion -- it is definitely a cleaner way to think about
it,
> and I removed the calls in postGenerateForm, replacing them with this:
>
> function preGenerateForm(){
> $options = array('minYear'=>1924,
> 'maxYear'=>1990,
> 'addEmptyOption'=>true,
> 'format'=>'dMY');
>
> $QF_date = new HTML_QuickForm_date('DOB', 'Date of Birth',$options);
> $this->preDefElements['DOB'] = $QF_date;
> }
>
> [I'm using an earlier version of FormBuilder, before the fb_ prefixes
(version
> 0.9.0).]
> It does create the element as desired, with the proper minYear and maxYear
--
> but the behaviour is still the same -- not displaying dates before 1969
but
> displaying them corerctly after 1969. Any thoughts? An obscure setting
> somewhere? Still messed-up syntax?
>
> Thanks.
>
> >
> >
> > > $options = array('minYear'=>1924,
> > > 'maxYear'=>1990,
> > > 'addEmptyOption'=>true,
> > > 'format'=>'dMY');
> > >
> > > $QF_date = new HTML_QuickForm_date('DOB', 'Date of
> > > Birth',$options);
> > > $QF_date->setValue($this->DOB); // the date from the db, formatted
> > > 1969-02-14
> > > $form->addElement($QF_date);
> > > }
> > >
> > > Thanks -- Sarah
> > >
> >
> > --
> > Justin Patrin
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php