PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject_FormBuilder » Bug #422

date.php setValue() doesn't allow value set of emptyOptionValue

Details

Submitted2003-12-13 10:34 UTC
Fromorya at ntlworld dot com
Assignedmw21st
StatusClosed
PackageDB_DataObject_FormBuilder
PHP Version4.3.3
Roadmaps(Not assigned)

Comments

[2003-12-13 10:34 UTC] orya at ntlworld dot com

Description:
------------
The setValue() function of the date element does not allow to set
the value to the emptyOptionValue when addEmptyOption is
enabled.

Here is my fix to the code:

function setValue($value)
{
if ($value == $this->_options['emptyOptionValue'] &&
$this->_options['addEmptyOption']) {
$value = array(
'D','l','d','M','m','F','Y','y','h','H','i','s','a','A'
=> $this->_options['emptyOptionValue']
);
} elseif (!is_array($value)) {
// 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);
}

Also see "Re: [PEAR] FormBuilder Element Group Processing
Solution" in pear-general

[2004-03-14 18:05 UTC] mw21st at php dot net

This is not a FormBuilder bug, setValue() is a method of HTML_QuickForm's date elment.