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

processform not defined when crossLinkExtraFields in use

Details

Submitted2005-02-22 23:06 UTC
Fromandrew dot clark at ucsb dot edu
Assignedjustinpatrin
StatusBogus
PackageDB_DataObject_FormBuilder
PHP Version4.3.10
OSFreeBSD 4.10
Roadmaps(Not assigned)

Comments

[2005-02-22 23:06 UTC] andrew dot clark at ucsb dot edu

Description:
------------
adding a crosslink fails if the crosslink table has crossLinkExtraFields defined:

[Tue Feb 22 14:58:46 2005] [error] PHP Fatal error: Call to undefined function: processform() in /usr/local/share/pear/DB/DataObject/FormBuilder.php on line 2308

Without crossLinkExtraFields defined, it works fine.

Reproduce code:
---------------
<?php
/**
* Table Definition for net_contact
*/
require_once 'DB/DataObject.php';

class DataObjects_Net_contact extends DB_DataObject
{

###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */

var $__table = 'net_contact'; // table name
var $net_contact_id; // int(16) not_null primary_k ey unsigned
var $net_id; // int(16) not_null unsigned
var $contact_id; // int(16) not_null unsigned
var $role; // string(9) enum
var $last_modified; // timestamp(14) not_null unsigned ze rofill timestamp
var $last_verified; // timestamp(14) not_null unsigned ze rofill

/* ZE2 compatibility trick*/
function __clone() { return $this;}

/* Static get */
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObject s_Net_contact',$k,$v); }

/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE

var $fb_enumFields = array('role');

var $fb_dateFields = array('last_modified', 'last_verified');

var $fb_selectAddEmpty = array('role');

var $fb_crossLinkExtraFields = array('role');
}
?>

Actual result:
--------------
Fatal error:

[Tue Feb 22 14:58:46 2005] [error] PHP Fatal error: Call to undefined function: processform() in /usr/local/share/pear/DB/DataObject/FormBuilder.php on line 2308

[2005-02-22 23:25 UTC] andrew dot clark at ucsb dot edu

I should give more detail. I've got two tables, contact and net, which are linked via net_contact. In this case, I'm attempting to link contacts to a net (from the net object form) by selecting the relevant contacts in the automatically generated crossLinks select box.

[2005-02-23 02:09 UTC] andrew dot clark at ucsb dot edu

Here's some stripped down code that reproduces the problem:

<?php
require_once 'include/config.php';
require_once 'DB/DataObject/FormBuilder.php';

DB_DataObject::debugLevel(0);

$self =& DB_DataObject::factory('net');

if (PEAR::isError($self)) {
die ( $self->getMessage() );
}

$self->get(13);

$fb_options = array( 'elementNamePrefix' => $self->ident() );

$builder =& DB_DataObject_FormBuilder::create($self,$fb_options);

$form =& $builder->getForm();

$form->process(array(&$builder,'processForm'), false);

echo $form->toHtml();

?>

Here's the relevant stuff from config.php:

require_once 'PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);

require_once 'Validate.php';

define('DB_DATAOBJECT_NO_OVERLOAD',true);

$options =&
PEAR::getStaticProperty('DB_DataObject','options');

$prefix = '/usr/home/staff/aclark/perlcode/contact_db/php';

$contact_ini = parse_ini_file("$prefix/DataObjects/contact.ini", TRUE);

$config = parse_ini_file("$prefix/DataObjects/DataObject.ini", TRUE);

$options = $config['DB_DataObject'];

$_DB_DATAOBJECT_FORMBUILDER['CONFIG'] = $config['DB_DataObject_FormBuilder'];

and my ident() function:

function ident() {
$ident = false;
foreach ($this->keys() as $k) {
if ( isset($this->$k) ) {
$ident .= $k.$this->$k;
}
}

return $ident === false ? false : md5($ident);
}

[2005-02-23 18:12 UTC] andrew dot clark at ucsb dot edu

Same fatal PHP error. I've put the code you posted just after the two 'require_once' lines so that it overrides the error handling I've set in 'include/config.php'.

[2005-02-23 19:46 UTC] andrew dot clark at ucsb dot edu

I notice that the form deleted any rows in the crosslink table with the id of the DataObject that my sample code is handling (id 13). You wanted that extra code in FormBuilder.php, before line 2308?

Here's the output (111 is the id of the contact object I'm linking to the net in this case)

c1eb2f08511bf34421c48c13464595fc__crossLink_net_contact__111_
_
stdClass Object
(
[fieldsToRender] => Array
(
[0] => net_id
[1] => contact_id
)

)

[2005-02-23 23:01 UTC] andrew dot clark at ucsb dot edu

The output with the other print_r

print_r($this->_extraFieldsFb);

looks a little more useful, so here it is

(I linked to a different contact in this case, so the id is 56 instead of 111):

c1eb2f08511bf34421c48c13464595fc__crossLink_net_contact__56_
_
Array
(
[c1eb2f08511bf34421c48c13464595fc__crossLink_net_contact__56__] => stdClass Object
(
[fieldsToRender] => Array
(
[0] => net_id
[1] => contact_id
)

)

)

[2005-03-11 05:29 UTC] andrew dot clark at ucsb dot edu

This behavior seems to have disappeared with 0.12.1 and latest DataObject and DB.