#25193 [NEW]: setDefaults for hierselect has to preceed addElement

From: Date: Thu, 21 Aug 2003 15:32:36 +0000
Subject: #25193 [NEW]: setDefaults for hierselect has to preceed addElement
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20287@lists.php.net to get a copy of this message
From: keith at midnighthax dot com Operating system: n/a PHP version: 4.3.2 PHP Bug Type: PEAR related Bug description: setDefaults for hierselect has to preceed addElement 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 bug report at http://bugs.php.net/?id=25193&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25193&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25193&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25193&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25193&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25193&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25193&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25193&r=support Expected behavior: http://bugs.php.net/fix.php?id=25193&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25193&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25193&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25193&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25193&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25193&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25193&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25193&r=gnused

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