Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #15955 On heirselect when you have more than two selects sub selects are not cleared
Submitted: 2009-02-27 06:16 UTC
From: nickknight Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: 5.2.4 OS: Ubuntu Linux yaaa 2.6.24-21-386
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 36 - 21 = ?

 
 [2009-02-27 06:16 UTC] nickknight (Nick Knight)
Description: ------------ The sub selection of the heirselect do clear down the lower values when values up the chain are selected. Test script: --------------- require_once "HTML/QuickForm.php"; $form = new HTML_QuickForm('edit_template_form', 'post'); $sel =& $form->addElement('hierselect', 'subjecttypeid', 'Subject Type', null, ' - '); $mainOptions = array(1 => 'TV Shows', 2 => 'Movies', 5=>'Rubbish'); $secOptions = array(1 => array(5 => 'Stargate Atlantis', 4 => 'hello'), 2 => array(1 => 'Romance')); $thirdOptions = array(1 => array(5 => array(1 => 'Blah')), 2 => array(1 => array(21 => "ksjdhfks"))); $opts = array($mainOptions, $secOptions, $thirdOptions); //print_r($opts); $sel->setOptions($opts); $form->addElement('submit','Save','Save'); $form->display(); Expected result: ---------------- When using this example I expect to see 3 select boxes prodced - which are. When you select 'Rubbish' on the first select box I expect to see all subsequent boxes cleared. Actual result: -------------- The third box is not cleared. The value is whateer was in before from the previous tree selection. Many thanks Nick

Comments

 [2009-02-27 20:18 UTC] nickknight (Nick Knight)
in file heirselect.php: function _hs_findOptions(ary, keys) { // adding this bit fixes it if (ary==undefined) { return {}; } // end of fix var key = keys.shift(); if (!key in ary) { return {}; } else if (0 == keys.length) { return ary[key]; } else { return _hs_findOptions(ary[key], keys); } }
 [2009-04-04 03:13 UTC] avb (Alexey Borzov)
-Assigned To: +Assigned To: avb
I'll check the proposed fix, but please note that empty <select></select> tag that you desire is invalid in [X]HTML. Thus a better idea is to have options in second and third selects corresponding to value in the first one, even if these options read "N/A" or similar.
 [2009-04-05 02:40 UTC] avb (Alexey Borzov)
-Status: Assigned +Status: Closed
Applied the proposed fix. Thanks!