Re: QuickForm checkboxes and their return values [solved]
| From: | Mitch Anderson | Date: | Fri, 19 Nov 2004 19:30:05 +0000 |
| Subject: | Re: QuickForm checkboxes and their return values [solved] | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15699@lists.php.net to get a copy of this message | ||
On Fri, 2004-11-19 at 11:17 -0800, Justin Patrin wrote:
> Ummm....you're forcing the checkbox to be checked here if it's checked
> in the DB. You should only do this if the form hasn't been submitted.
> I.e. in the } else { section below.
Thank you! I figured it was something simple I was doing wrong...
I changed it to now read like this...
$form = new HTML_QuickForm('Form');
$checked =& $form->addElement('checkbox', 'check1', NULL,
'CheckMe',
null);
$form->addElement('submit', null, 'Submit');
if($form->validate()){
$checked = $form->exportValue('check1');
if($checked){
$ret_array['check1'] = 1;
} else {
$ret_array['check1'] = 0;
}
} else {
if($data_array['check1'] == 1) { $checked->setChecked(true); }
$form->display();
}
--
Mitch Anderson <mitch@metauser.net>