Re: HTML_QuickForm_Date display before 1969

From: Date: Mon, 17 Jan 2005 23:20:37 +0000
Subject: Re: HTML_QuickForm_Date display before 1969
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16975@lists.php.net to get a copy of this message
On Mon, 17 Jan 2005 16:37:43 -0600, Sarah Gray <sarah@fabled.net> wrote: > Hi, > > Weird (to me) behaviour. I'm a little stuck on it. > > I have a date dropdown menu that displays the correct date *unless* the > date falls before unix epoch begins (12-31-1969). No matter what the > date is, if the date falls before 12-31-69, my date dropdown menu > displays 31-Dec-1969 . > > If the date is more recent than 1969, the dropdowns display the date > correctly. > > No matter what the date is, the form submits it correctly to the > database -- it is an error only in displaying dates pre-1969 -- ie, you > can pull the dropdowns down to whatever date you wish, and it will do > the inserts correctly, as well as retrieve the data correctly when you > echo it to the page. > > It's like the date is drawn before the menu knows it can display earlier > dates. I tried setting this in my php page as well as in > postGenerateForm, but it was the same either way. I feel I must be > missing something obvious, but I am still missing it. Does anyone have > a suggestion that would stop this? > > Code snippet: > > function postGenerateForm(&$form){ > > // removed so I could create a new element with minYear and maxYear > $form->removeElement('DOB'); > 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. > $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

« previous php.pear.general (#16975) next »