Re: QF: setting defaults for a radio group
| From: | Justin Patrin | Date: | Thu, 27 Apr 2006 17:28:30 +0000 |
| Subject: | Re: QF: setting defaults for a radio group | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23865@lists.php.net to get a copy of this message | ||
On 4/27/06, Damien Cros <damienc@cc.in2p3.fr> wrote:
> Hi,
>
> Here's what I have in my php file:
>
> $radio[] = HTML_Quickform::createElement('radio', null, null, null,
> 'value1');
> $radio[] = HTML_Quickform::createElement('radio', null, null, null,
> 'value2');
> $form->addGroup($radio, 'rdGroup', null);
> $radio[0]->setChecked(true);
>
> The last line works fine.
>
> If I had this somewhere in the file
> $form->addElement('text', 'txtField');
> $form->setDefaults(array('txtField'=>'some text'));
>
> Then the setChecked doesn't work anymore.
>
> How can I fix this?
> The name of the two radio elements are both the same: 'rdGroup' so I
> can't use it with setDefaults.
>
Don't use setChecked() or setValue(). They are basically worthless as
*anything* will override them. Use setDefaults() for everything.
--
Justin Patrin