#25193 [Opn->Ana]: setDefaults for hierselect has to preceed addElement
| From: | avb@php.net | Date: | Fri, 22 Aug 2003 12:00:37 +0000 |
| Subject: | #25193 [Opn->Ana]: setDefaults for hierselect has to preceed addElement | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20391@lists.php.net to get a copy of this message | ||
ID: 25193
Updated by: avb@php.net
Reported By: keith at midnighthax dot com
-Status: Open
+Status: Analyzed
Bug Type: PEAR related
Operating System: n/a
PHP Version: 4.3.2
-Assigned To:
+Assigned To: mansion
New Comment:
Clarification: if the commented line is uncommented, then the bug
surfaces, the current example works fine.
I think the problem is that hierselect uses group's 'updateValue' event
handler, but should really behave like date, where element's handler is
used. Bertrand?
Previous Comments:
------------------------------------------------------------------------
[2003-08-21 10:32:36] keith at midnighthax dot com
Description:
------------
HTML_QuickForm, hierselect element
If a setDefaults is applied before the addElement line, only the Main
hierselect box is set to the default. If applied after the addElement
line it works correctly.
The example code shows the bug; if the existing setDefaults line is
commented out, and commented-out one uncommented, it works fine.
Reproduce code:
---------------
$main[0] = "England";
$main[1] = "Scotland";
$main[2] = "USA";
$secondary[0][0] = "London";
$secondary[0][1] = "Manchester";
$secondary[0][2] = "Liverpool";
$secondary[1][3] = "Edinburgh";
$secondary[1][4] = "Glasgow";
$secondary[2][5] = "Fort Worth";
$secondary[2][6] = "Boston";
$secondary[2][7] = "Los Angles";
$form->setDefaults(array('location'=>array(1,4)));
$sel =& $form->addElement('hierselect', 'location',
'Location:');
$sel->setMainOptions($main);
$sel->setSecOptions($secondary);
$form->addElement('submit', 'btnSubmit', 'Submit');
#$form->setDefaults(array('location'=>array(1,4)));
$form->display();
Expected result:
----------------
Main box showing 'Scotland', secondary box showing 'Glasgow'.
Actual result:
--------------
Only the main hierselect box default is set, so the display is
"Scotland" "London".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25193&edit=1