Re: QF: setDefaults() weird behaviour
| From: | toni | Date: | Thu, 18 Nov 2004 13:04:09 +0000 |
| Subject: | Re: QF: setDefaults() weird behaviour | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15630@lists.php.net to get a copy of this message | ||
hi,
my problem is similar. I get wrong values in a select box. I tried with:
$t = new Tema();
$_temas = $t->lista();
$this->addElement('select', 'temas', 'Temas:', $_temas,
array('size'=>5,'multiple'=>'multiple'));
$tt = $this->getElement ("temas");
$tt->setSelected(array_keys($_temas));
but don't works.
Toni.
El dl 15 de 11 del 2004 a les 10:47 -0800, en/na Justin Patrin va
escriure:
> 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
>