#25193 [Ana->Csd]: setDefaults for hierselect has to preceed addElement

From: Date: Sun, 07 Sep 2003 13:50:19 +0000
Subject: #25193 [Ana->Csd]: setDefaults for hierselect has to preceed addElement
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21137@lists.php.net to get a copy of this message
ID: 25193 Updated by: mansion@php.net Reported By: keith at midnighthax dot com -Status: Analyzed +Status: Closed Bug Type: PEAR related Operating System: n/a PHP Version: 4.3.2 Assigned To: mansion New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Thanks Keith. Previous Comments: ------------------------------------------------------------------------ [2003-08-22 07:00:37] avb@php.net 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? ------------------------------------------------------------------------ [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

« previous php.pear.dev (#21137) next »