Re: FormBuilder Element Group Processing Solution

From: Date: Sat, 13 Dec 2003 14:42:25 +0000
Subject: Re: FormBuilder Element Group Processing Solution
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9504@lists.php.net to get a copy of this message
Orya wrote:
Okay. So initally, I needed to add the "--" item at the top of the select menus. I checked out the date element class and found that it already supports this and that you can turn on the feature when creating the element. So in my Programs data object I added a preGenerateForm() :
Ah cool, obviously I didn't poke the QuickForm docs enough, I always ended up generating the empty option myself until now (/me bashes head on desk)... I guess I'll integrate this into FormBuilder directly.
Problem was, when I selected the "--" options for a date field which would result in an array of 3 null elements (day, month, year), FormBuilder would send this array to it's internal function _array2date() which would return the current date. This resulted in the dataobject being updated with the current date, I wanted it to be updated with NULL in this case. So then I created a preProcess() function in the data object (gets called before FormBuilder's processForm()): [...]
Urgh, that's ugly. I mean, it works and currently seems to be the only way, but it's ugly. I'll have to make that check in FormBuilder itself. Also, the date handling in FormBuilder is pretty unflexible right now, but I currently don't have a good idea for it. I guess I'll add an option for defining your own callback functions that can be used as an alternative for the FormBuilder methods, so at least that should gain some more flexibility. CU Markus

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