Re: HTML_Quickform and setDefaults for radio group

From: Date: Mon, 21 Jun 2004 15:23:27 +0000
Subject: Re: HTML_Quickform and setDefaults for radio group
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13232@lists.php.net to get a copy of this message
On Mon, 21 Jun 2004 17:04:41 +0200, Bertrand Mansion <bmansion@mamasam.com> wrote: > > > Tizzle wrote: > > >I am trying to set the default value for a group of radio buttons as > >follows, with no luck: > > > >$radios[] = &HTML_QuickForm::createElement('radio', 'sex', null, > >'man', 'm'); > >$radios[] = &HTML_QuickForm::createElement('radio', 'sex', null, > >'vrouw', 'f'); > > > >$uploadForm->setDefaults(array('sex','m')); > > > >$uploadForm->addGroup($radios, null, 'Geslacht:', '&nbsp;'); > > > >as far as i can see this is exactly according to the manual but no > >default is set... > > The way you add the radios is not correct. > > $radio[0] =& HTML_QuickForm::createElement('radio', null, null, 'man', > 'm'); > $radio[1] =& HTML_QuickForm::createElement('radio', null, null, > 'vrouw', 'f'); > $radio[2] =& HTML_QuickForm::createElement('radio', null, null, > 'other', 'o'); > $uploadForm->addGroup($radio, 'sex', 'Geslacht:', > '&nbsp;'); > > $uploadForm->setDefaults(array('sex' => 'o')); > > Bertrand Mansion > Mamasam > > PS: Feel free to remove the third option if you don't need it :D > thnx Bertrand. That did the trick. That third option is a discussion i will have to have with my client ;) Tijs

« previous php.pear.general (#13232) next »