Re: quickform : setChecked doesn't work
| From: | Justin Patrin | Date: | Thu, 28 Dec 2006 19:26:33 +0000 |
| Subject: | Re: quickform : setChecked doesn't work | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26223@lists.php.net to get a copy of this message | ||
On 12/26/06, pear@elfloridita.net <pear@elfloridita.net> wrote:
Hi I have a quickform form with two radio input. I want the first one to be checked when the page is loaded. I tried : $radios[] = &HTML_QuickForm::createElement('radio', null, null, 'label1', 'val1', array('class' => 'radio'); $radios[] = &HTML_QuickForm::createElement('radio', null, null, 'label2', 'val2', array('class' => 'radio'); $radios[0]->setChecked(true); $form->addGroup($radios, 'grp', 'Label'); but that doesn't work, nothing's checked. I also tried : $radios[] = &HTML_QuickForm::createElement('radio', null, null, 'label1', 'val1', array('class' => 'radio', 'checked' => 'checked'); $radios[] = &HTML_QuickForm::createElement('radio', null, null, 'label2', 'val2', array('class' => 'radio'); $radios[0]->setChecked(true); $form->addGroup($radios, 'grp', 'Label'); but the checked parameter is ignored (doesn't appear in HTML source) Can someone help me ?Try using $form->setDefaults(). -- Justin Patrin