Re: QF: setDefaults() weird behaviour
| From: | Justin Patrin | Date: | Mon, 15 Nov 2004 18:47:13 +0000 |
| Subject: | Re: QF: setDefaults() weird behaviour | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15529@lists.php.net to get a copy of this message | ||
On Sun, 14 Nov 2004 21:39:12 +0100, Martin Braun
<uvsm@stud.uni-karlsruhe.de> wrote:
> hey there,
>
> I' having some trouble with setDefaults() at the mom. heres my code:
>
> <code>
> $form->setDefaults($defaults);
>
> foreach ($editoptions as $id => $title) {
> $form->addElement('checkbox', 'chk'.$id, null, $title);
> }
> </code>
>
> so my form contains lots of checkboxes named chk0, chk1, chk2 and so on.
> $defaults looks like this: array('chk0' => true, 'chk1' => true).
>
> the problem is: the checkboxes aren't checked by default - unless I
> reload the page (not submitting the form or anything, just reloading the
> page).
>
> can anyone help?
>
I don't think that you can use setDefaults() to check checkboxes. Try
using setChecked() on the checkbox elements instead.
--
Justin Patrin