PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #1975

setDefaults doesn't work with an array of groups

Details

Submitted2004-07-25 04:19 UTC
Frompear at dodgeit dot com
StatusBogus
PackageHTML_QuickForm
PHP Version4.3.8
OSWindows XP Pro
Roadmaps(Not assigned)

Comments

[2004-07-25 04:19 UTC] pear at dodgeit dot com

Description:
------------
If I set grouped elements like an array, setDefaults won't set it at all.

FWIW, setting the groups like an arry works like a charm, just not the setDefaults(). The reason I need to do the array is because my form has a header field and multiple rows (eg: headers - name, phone, email and each row lets the user input their contact info).

Reproduce code:
---------------
See HTML/docs/renderers/SmartyDynamic_example.php

~Line 18
$form->setDefaults(array(
'itxtTest' => 'Test Text Box',
'itxaTest' => 'Hello World',
'iselTest' => array('B', 'C'),
'name' => array('first' => 'Thomas', 'last' => 'Schulz'),
'iradYesNo' => 'Y',
// notice the [0] which was added
'ichkABCD[0]' => array('A'=>true,'D'=>true)
));

~Line 45
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
// again, the added [0]
$form->addGroup($checkbox, 'ichkABCD[0]', 'ABCD', array(' ', '<br />'));

Expected result:
----------------
the checkbox will have options A and D checked just as it did before adding [0]

Actual result:
--------------
no result at all, it's as if setDefault was never used for that group's element.