Re: HTML_QuickForm, advcheckbox, setChecked()
| From: | Paul M Jones | Date: | Sun, 18 Apr 2004 00:24:36 +0000 |
| Subject: | Re: HTML_QuickForm, advcheckbox, setChecked() | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-27895@lists.php.net to get a copy of this message | ||
On Apr 17, 2004, at 5:25 PM, Bertrand Mansion wrote:
<pmjones@ciaweb.net> wrote :Yes, that fixes it, will file a bug shortly. In the past, when I have needed behavior similar to the advanced checkbox, I have used a dual hidden + checkbox approach, instead of a JavaScript approach. For example...<?php require_once 'HTML/QuickForm.php'; require_once 'Var_Dump.php'; $elem =& HTML_QuickForm::createElement( 'advcheckbox', 'xbox', 'Label:', null, null, array(0,1) ); $elem->setValue(1); Var_Dump::display($elem); $form =& new HTML_QuickForm(); $form->addElement($elem); $form->display(); Var_Dump::display($form); ?>Thanks for the test case. Looks like line 250 of advcheckbox.php should read:if (null !== $value) { $this->setValue($value); }Could you please test and file a bug :)
<input type="hidden" name="my_checkbox" value="not-checked" />
<input type="checkbox" name="my_checkbox" value="checked" />
... so that the 'not-checked' value comes back if the box is not checked, and if it is, the 'checked' value comes back instead (it overrides the earlier value).
Is this a valid and standards-compatible approach? I ask only because HTML_QuickForm might be able to make use of it, instead of the JavaScript, thus tightening things up just a little bit. Just asking about practices; not a critique, the current behavior is just fine.
Thanks again for your quick responses. :-)
--
Paul M. Jones
pmjones@ciaweb.net
Savant: the simple alternative to Smarty.
http://phpsavant.com/