Re: Quickform - set check group radio

From: Date: Thu, 07 Dec 2006 11:23:48 +0000
Subject: Re: Quickform - set check group radio
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26003@lists.php.net to get a copy of this message
Hi, Francesco F wrote:
I have a form with a text box 2 radio button (in a group); i'd like to set default value for one radio, but it doesn't go. This is my code: $radio['off'] =& HTML_QuickForm::createElement('radio', 'forward_enable', '1','Disabilitato','off'); $radio['on'] =& HTML_QuickForm::createElement('radio', 'forward_enable', '2','Abilitato','on'); $radio['on']->setChecked(true); $form->addGroup($radio, 'forward_enable', 'Forward ', '-', false); If display object (by $radio['on']->display) it is check but if I display form (by $form->display), my radio isn't check
When you add an element to the form, its value is updated from the form's values. Basically that means that you should call setValue() / setChecked() *after* the element is added or use setDefaults() on the form.

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