php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25193 setDefaults for hierselect has to preceed addElement
Submitted: 2003-08-21 10:32 UTC Modified: 2003-09-07 09:50 UTC
From: keith at midnighthax dot com Assigned: mansion (profile)
Status: Closed Package: PEAR related
PHP Version: 4.3.2 OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: keith at midnighthax dot com
New email:
PHP Version: OS:

 

 [2003-08-21 10:32 UTC] 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".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-22 07:00 UTC] 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-09-07 09:50 UTC] mansion@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 08:02:42 2024 UTC