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 #1931

Associative array options call not working in create

Details

Submitted2004-07-21 00:33 UTC
Frommarcelo at beteltecnologia dot com dot br
Assignedjustinpatrin
StatusClosed
PackageDB_DataObject_FormBuilder
PHP Version4.3.7
OSWindows XP
Roadmaps(Not assigned)

Comments

[2004-07-21 00:33 UTC] marcelo at beteltecnologia dot com dot br

Description:
------------
calling create method with associative array options didn“t work for change of form_header_text.

I managed to find the problem:
Since default form_header_text is set to null, isset equals false, the code in the constructor is preventing the setting, especifically the if (isset($this->$key)) in the loop for $options. Below I point the broken code at the class constructor.

Reproduce code:
---------------
function DB_DataObject_FormBuilder(&$do, $options=false)
{
global $_DB_DATAOBJECT_FORMBUILDER;
// Set default callbacks first!
$this->_dateToDatabaseCallback = array($this,'_array2date');
$this->_dateFromDatabaseCallback = array($this,'_date2array');

// Read in config
if (is_array($options)) {
reset($options);
while (list($key, $value) = each($options)) {
if (isset($this->$key)) { //<=PROBLEM FOR $this->form_header_text!
$this->$key = $value;
}
}
}
...

Expected result:
----------------
I only ask: Why is this condition being tested since I am setting the variable and should'nt matter if it is or not already set?

Thanks and keep going because your class is very nice!