Re: Problem with quickform checkbox
| From: | Alexey Borzov | Date: | Tue, 22 May 2007 18:04:43 +0000 |
| Subject: | Re: Problem with quickform checkbox | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27350@lists.php.net to get a copy of this message | ||
Hi,
Eugen Stoianovici wrote:
I have a form with a few checkboxes used for updating some entrys. The problem is that if i use checkbox::setChecked(true), the checkbox remains checked even if the user unchecks itLooks like it is already reported as a bug: http://pear.php.net/bugs/bug.php?id=11047 The workaround, as was already mentioned, is to use setDefaults() rather than setChecked(), but I think this behaviour still needs to be fixed. Expect QuickForm 3.2.8 Really Soon Now as I'm currently doing releases for all the packages I maintain.
here's the code: $form = new HTML_QuickForm('events','POST',$_SERVER[REQUEST_URI],NULL,true); $form->addElement('text', 'ca', 'CA:'); $rmodem =& $form->addElement('checkbox', 'rmodem', 'Reset modem:'); $rsoft =& $form->addElement('checkbox', 'rsoft', 'Reset soft:'); $rhard =& $form->addElement('checkbox', 'rhard', 'Reset hard:'); $form->addElement('text', 'phone, 'phone:'); if($def["rhard"]>0) $rhard->setChecked(true); if($def["rmodem"]>0) $rmodem->setChecked(true); if($def["rsoft"]>0) $rsoft->setChecked(true); if($form->validate()){ $form->freeze(); savedata($form); } echo $form->toHtml(); If rhard is checked in the inital display and the user unchecks it, form->freeze still sees it checked what am i doing wrong?