Re: [Quickform] pass by reference problem
| From: | Bertrand Mansion | Date: | Mon, 21 Jul 2003 22:42:25 +0000 |
| Subject: | Re: [Quickform] pass by reference problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6696@lists.php.net to get a copy of this message | ||
<ghopson@mac.com> wrote :
> Hi,
>
> I just upgraded to HTML_Quickform 3.1 from 2.x - a big leap,
> apparently! Oh, and I changed PHP from 4.1.1 to 4.3.2 at the same
> time...fatal!
>
> I am creating a form, and passing the form into a function on a class
> so that the class could populate the form with fields pertinent to that
> class. Before today this worked. The code kinda looks like this:
>
> class MyInvoice
> {
> ...
> function buildForm( &$form) {
> $form->addElement(...); etc.
> }
> }
>
> And, in my page...
>
> $form = &new HTML_Quickform('myname', 'POST');
> $myInstance = &new MyInvoice();
> $myInstance->buildForm($form);
>
> If I log out the $form value before and after the call to buildForm,
> the values are the same. If I log the value of the form inside the
> buildform function, then I see all my elements. It's as if the form is
> not passed by reference, and the changes I make to it are not reflected
> in the calling code.
>
> Anyone have any insight? I guess it's more of a PHP problem as opposed
> to PEAR::Quickform, but everything else seems to be working OK.
No insight, sorry. Maybe try:
$form = new HTML_Quickform('myname', 'POST');
$myInstance = &new MyInvoice();
$myInstance->buildForm($form);
As there's no need to have a reference to the new QuickForm instance.
Tell me if you find anything new, maybe we can sort this out.
Bertrand Mansion
Mamasam