FormBuilder::useCallTimePassByReference

From: Date: Thu, 10 Mar 2005 18:23:15 +0000
Subject: FormBuilder::useCallTimePassByReference
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17951@lists.php.net to get a copy of this message
Hello, Can someone help me make sense of what is going on here? I have a DataObject for which I defined a postGenerateForm callback: class DataObjects_User_FormSignIn extends DB_DataObject { ###START_AUTOCODE . ###END_AUTOCODE var $fb_fieldsToRender = array( 'username', 'pwd' ); var $fb_fieldLabels = array( 'username' => 'Username', 'pwd' => 'Password' ); function postGenerateForm( &$form ) { ..change a property or two on the form. print_r( $form ); } } I can see from the print_r that the changes I make to form are there. Then I get my form object $builder = &DB_DataObject_FormBuilder::create( $myDataObject ); $form = $builder->getForm(); Now if I do a print_r on the form object my changes are lost - unless I modify the line in FormBuilder.php responsible for calling the postGen callback to: $this->_do->postGenerateForm(&$obj, $this); So it seems like I am supposed to set useCallTimePassByReference to TRUE but I haven't seen people doing this in the few examples I've found or really mention it. My allow_call_time_pass_reference is set to 'On' and I would prefer to keep it this way since my hosted production environment uses this setting. I have been around the programming block but am pretty new to PHP so it could be that I'm not understanding PHP references properly. I thought that "function postGenerateForm( &$form )" meant that $form would get passed by reference into the function. Can anyone help me to understand why the form var is being passed by value to my callback unless I tweak FormBuilder? Thanks Brian

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