Re: FormBuilder Element Group Processing Solution
| From: | Bertrand Mansion | Date: | Sat, 13 Dec 2003 10:23:22 +0000 |
| Subject: | Re: FormBuilder Element Group Processing Solution | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9499@lists.php.net to get a copy of this message | ||
<orya@ntlworld.com> wrote :
> Here I ran into another problem. Once the NULL value was stored in
> the database, when it came to redrawing the form the date element
> would display the current date even. This is even though the
> equivalent field in the database was set to NULL. I traced this to
> the date element's setValue() function. What happens is that
> FormBuilder's _generateForm() function would get the data object and
> call the setValue() function passing the equivalent data object's
> field as a parameter. When it got to the date field it called,
> essentially, setValue(null). Unfortunately, the date element
> interprets this to mean the current date. I think this behavior is
> wrong when the "addEmptyOption" is enabled otherwise there is no way
> to set the element's value to the empty option! So I actually went in
> and patched the setValue to:
>
> function setValue($value)
> {
> if ($this->_options['addEmptyOption'] && !$value) { //added
> to allow setting of empty option
> $value = array(
>
> 'D','l','d','M','m','F','Y','y','h','H','i','s','a','A'
> => $this->_options['emptyOptionValue']
> );
> } elseif (!is_array($value)) { //original code
> // might be a unix epoch, then we fill all possible values
> $arr = explode('-', date('w-d-n-Y-y-h-H-i-s-a-A', (int)$value));
> $value = array(
> 'D' => $arr[0],
> 'l' => $arr[0],
> 'd' => $arr[1],
> 'M' => $arr[2],
> 'm' => $arr[2],
> 'F' => $arr[2],
> 'Y' => $arr[3],
> 'y' => $arr[3],
> 'h' => $arr[4],
> 'H' => $arr[5],
> 'i' => $arr[6],
> 's' => $arr[7],
> 'a' => $arr[8],
> 'A' => $arr[9]
> );
> }
> parent::setValue($value);
> }
>
> Would it be possible to get the official code updated to include this?
I liked your explanations, they were very clear :)
Could you please file a bug for this on pear.php.net so that we remember to
fix that for the next release ?
Thanks,
Bertrand Mansion
Mamasam