Bug #15955 [Opn]: On heirselect when you have more than two selects sub selects are not cleared
| From: | borz_off at cs dot msu dot su | Date: | Fri, 03 Apr 2009 22:13:50 +0000 |
| Subject: | Bug #15955 [Opn]: On heirselect when you have more than two selects sub selects are not cleared | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-303@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=15955&edit=1
ID: 15955
Updated by: borz_off@cs.msu.su
Reported By: nick at omniis dot com
Summary: On heirselect when you have more than two selects sub
selects are not cleared
Status: Open
Type: Bug
Package: HTML_QuickForm
Operating System: Ubuntu Linux yaaa 2.6.24-21-386
PHP Version: 5.2.4
-Assigned To:
+Assigned To: avb
Roadmap Versions:
New Comment:
-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.
Previous Comments:
------------------------------------------------------------------------
[2009-02-27 15:18:19] nickknight
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-02-27 01:16:16] nickknight
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
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=15955&edit=1