Re: QF or FB: how to allow a NULL for date field?

From: Date: Sat, 08 Jan 2005 02:41:58 +0000
Subject: Re: QF or FB: how to allow a NULL for date field?
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16815@lists.php.net to get a copy of this message
On Fri, 7 Jan 2005 18:27:10 -0800 (PST), l Burnerheimerton <lburnerheimerton@yahoo.com> wrote: > What I have so far is this: > > function preGenerateForm() { > $opt = array('Y' => 2002, 'M' => 12, 'd' => 28); > $this->fb_selectAddEmpty['dateSTAT'] = > HTML_QuickForm::createElement('date', 'dateSTAT', > 'Date STAT: ',$opt); Get rid of that, you don't need it. > } > var $fb_selectAddEmpty = array('dateSTAT'); The above line is right. > > It displays an empty choice but still defaults to > todays date. How do I get it to default to the empty > selection choice? > > I see no option for setting the default - yes I RTM. > If I set it directly, it overrides the record on edit. The _date2Array function converts NULL to the current date. You could define your own dateFromDatabaseCallback to handle this. > > > --- Justin Patrin <papercrane@gmail.com> wrote: > > > Please send text e-mails to the list, not HTML. Your > > inline comments > > are nearly indistinguishable from the mail I sent > > earlier. > > > > On Fri, 7 Jan 2005 13:51:34 -0800 (PST), l > > Burnerheimerton > > <lburnerheimerton@yahoo.com> wrote: > > > Justin Patrin <papercrane@gmail.com> wrote: > > > > > > > > > On Fri, 7 Jan 2005 12:27:12 -0800 (PST), l > > Burnerheimerton > > > wrote: > > > > I have several forms where that track status of > > a process. I have been > > > building the forms based on using a date field - > > if datefiled = '0000-00-00' > > > //default for database field, then that status has > > not happened yet. > > > > > > > > However, when using either QuickForm or > > FormBuilder, the date field is > > > generated in such a way that it will always enter > > a date in the field. > > > > > > > > OPTION 1 - figure out a way around this. > > > > > > > > OPTION 2 - restructure my tables to add an > > additional field (Yes/No) to > > > track each status. > > > > > > > > Your thoughts? > > > > > > > > > > Do you allow "null" in the date fields? Try > > putting the date field in > > > fb_selectAddEmpty. > > > > > > Here's what I tried: > > > > > > $this->fb_selectAddEmpty['dateStatusA'] = > > > HTML_QuickForm::createElement('date', > > 'dateStatusA', 'Status A Completed: > > > '); > > > > RTFM > > > > http://opensource.21st.de/tiki-index.php?page=Formbuilder+configuration+options#id487538 > > This is an array of field *names*. You only put > > element objects in > > preDefElements. > > > > > > > > It did not present an empty data selection - > > displayed the nornal select > > > 1-31 for days, 1 - 12 for months... > > > > > > I don't think your other option would because when > > the form is displayed it > > > defaults to todays date. If no date is selected, > > that date - the default > > > date - is inserted in to the database. That MIGHT > > be the actual date the > > > user intended or maybe not. > > > > > > The only way I can tell is if the default data is > > 0000-00-00. > > > > > > If I can't get an empty default - my preference - > > to work, is there an > > > option for offering selection dates through an > > array consisting of a default > > > of 0000-00-00 and year 2001 - 2010? Right now, I > > can only see that if I > > > want the lower range to 0000-00-00 it will create > > 2005 selection choices for > > > years. > > > > > > Thanks for any ideas! > > > > > > > > > If that doesn't work you can also use > > preProcessForm to check for a > > > "null" date and either set it to "0000-00-00" or > > > DB_DataObject_Cast::sql('NULL'); > > > > > > > -- > > Justin Patrin > > > > -- > > PEAR General Mailing List (http://pear.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- Justin Patrin

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