QuickForm and advcheckbox
| From: | Birgir Stefansson | Date: | Mon, 11 Nov 2002 12:47:14 +0000 |
| Subject: | QuickForm and advcheckbox | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-2695@lists.php.net to get a copy of this message | ||
I have been using HTML_QuickForm for some time now and this package has
helped me a lot and made my life a whole lot easier :)
Now I was thinking about using advcheckbox instead of checkbox but I'm a
little bit puzzled about how to set the default value for the
advcheckbox vs. checkbox.
<?
require_once ("HTML/QuickForm.php");
$form = new HTML_QuickForm('frmTest', 'POST');
$defaultValues['ichkTest'] = true;
$defaultValues['iadvchkTest'] = true;
$form->setDefaults($defaultValues);
print_r($defaultValues);
$form->addElement('checkbox', 'ichkTest', 'Test CheckBox:',
'Check the
box');
$form->addElement('advcheckbox', 'iadvchkTest', 'Test
AdvCheckBox:',
'Check the box');
if ($form->validate()) {
// Form is validated, then processes the data
$form->freeze();
$form->process();
echo "\n<HR>\n";
}
$form->display();
?>
The following displays one checkbox and one advcheckbox.
I am trying to set both the checkboxes to be 'checked'.
I do get the intended result with the first one which is just a normal
checkbox which gets checked.
The second checkbox, advcheckbox, does not get checked no matter what
value I set as default value.
Is there no way to set the default value as checked for advcheckbox ?
Thanks.
Birgir