#80 [Opn->WFx]: HTML_QuickForm::addElement($element) dosen't pass by reference
| From: | avb@php.net | Date: | Thu, 09 Oct 2003 07:51:20 +0000 |
| Subject: | #80 [Opn->WFx]: HTML_QuickForm::addElement($element) dosen't pass by reference | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-22511@lists.php.net to get a copy of this message | ||
ID: 80
Updated by: avb@php.net
Reported By: marba126 at student dot liu dot se
-Status: Open
+Status: Wont fix
Bug Type: HTML_QuickForm
Operating System: Windows 98 SE
PHP Version: Irrelevant
New Comment:
There is no easy fix for this, as addElement() has to also accept the
element type (usually a constant) as its first parameter and thus it
cannot be passed by reference.
The easiest workaround would be to use just addElement() instead of
createElement()/addElement():
<?php
require_once ("HTML/QuickForm.php");
$form = new HTML_QuickForm();
$text =& $form->addElement('text', 'testText', 'This should be
"Set
after addElement() call" :', 'size=40');
$text->setValue("Set after addElement() call");
$form->display();
?>
Previous Comments:
------------------------------------------------------------------------
[2003-10-08 16:08:41] marba126 at student dot liu dot se
Description:
------------
Unexpected beaviour: using $element->setValue(), after $element has
been added to the form with addElement($element), will have no effect.
This is probably because addElement() dosen't pass by reference. Thus
addElement() creates a copy of the element you added (which will not be
affected when you change the origin element).
HTML_QuickForm ver. 3.1.1
Reproduce code:
---------------
<?php
require_once ("HTML/QuickForm.php");
$form = new HTML_QuickForm();
$text =& $form->createElement('text', 'testText', 'This should be
"Set
after addElement() call" :', 'size=40');
$text->setValue("Set before addElement() call");
$form->addElement($text);
$text->setValue("Set after addElement() call");
$form->display();
?>
Expected result:
----------------
The value of the text input field is expected to be "Set after
addElement() call" when form is displayd.
Actual result:
--------------
The value of the text input field is "Set before addElement() call"
when form is displayd.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=80&edit=1