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

From: Date: Fri, 07 Jan 2005 22:05:44 +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-16811@lists.php.net to get a copy of this message
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

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