Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #400 Element object cannot be passed by reference from one user method to another
Submitted: 2003-12-10 20:23 UTC
From: ate2 at cornell dot edu Assigned: mansion
Status: Closed Package: HTML_QuickForm
PHP Version: 4.3.3 OS: RedHat Linux 7.3
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 47 - 43 = ?

 
 [2003-12-10 20:23 UTC] ate2 at cornell dot edu
Description: ------------ The following script requires DB_DataObject package as well. My goal was to make a base class with a method that behaves like HTML_QuickForm::addElement() but also does some other things to make sure the created element is properly associated with the DataObject property to which it pertains. This class would then be extended to a series of child classes, each corresponding to a data table (documented feature of DB_DataObject package). The problem is that the method I have written (_genField) does not pass the reference back to the invoking method (appendForm). Instead it appears to pass a copy of the element object. Consequently, the code runs without error messages, but the invoking method does not change the element in the actual form as desired. I have not been able to find an explanation for this and am too inexperienced to know whether this is a PHP bug or some sort of problem with these particular two PEAR modules. Any advice would be greatly appreciated. I have also included my present workaround(commented out), which is to use the HTML_QuickForm::getElement() method to generate a reference from the invoking method. This, however, adds a line of typing for every field I want to add to the form. PHP configure line: './configure' '--with-ldap' '--with-mysql' '--with-apxs=/usr/local/apache/bin/apxs' Reproduce code: --------------- http://safc.sas.cornell.edu/test/test_source.txt Expected result: ---------------- Field should read "I work" Actual result: -------------- Field reads "I do not work"

Comments

 [2003-12-10 20:29 UTC] ate2 at cornell dot edu
I realize that this was not apparent in my original submission and it is quite important: The problem *only* occurs when class Parent is an extension of DB_DataObject. The code works fine when Parent is not extended from another class. I have not tested to see what happens when other base classes are used.
 [2003-12-10 22:10 UTC] ate2 at cornell dot edu
This bug should be closed. Further information in PHP bug 25831 and DB_DataObject bug #172, which includes a solution. Problem is the result of use of overload() function in DB_DataObject class and it may be prevented by the following line of code: define('DB_DATAOBJECT_NO_OVERLOAD',true);
 [2003-12-11 00:04 UTC] mansion at php dot net
Then I'll close it :) BTW did you have a look at the DB_DataObject_FormBuilder package ? It might do what you are trying to do.