Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Bug #3167 checkbox type does not permitting setting a DB_DATAOBJECT_BOOL field to false
Submitted: 2005-01-11 20:09 UTC
From: ate2 at cornell dot edu Assigned: justinpatrin
Status: Closed Package: DB_DataObject_FormBuilder
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-01-11 20:09 UTC] ate2 at cornell dot edu
Description: ------------ The checkbox value only registers in a form if it is checked. Consequently an unchecked checkbox won't register at all. Thus you can set a boolean from false to true but not true to false with the present automatic type of DB_DATAOBJECT_BOOL fields. Better to use the otherwise identical "advcheckbox" type which uses javascript and hidden fields to add this functionality to the basic checkbox type. This has been working well for me. One small problem (with either checkbox) would be that it could be possible to have a NULL boolean field in which case there would be a third value to consider. Maybe should generate a select element with empty option for null bool fields? Reproduce code: --------------- // Assume user has unchecked the box $do =& new DataObject(); $do->boolVal = true; $fb =& new DataObject_FormBuilder($do); $form =& $fb->getForm(); if ($do->validate()) { $fb->processForm($form->exportValues()); if ($do->boolVal) { "Value is true"; } else { "Value is false"; } } echo $form->toHtml(); Expected result: ---------------- "Value is false" Actual result: -------------- "Value is true"

Comments

 [2005-01-12 02:38 UTC] justinpatrin
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. For a field where null is allowed....technically that's a third value, but I'm not sure how this should be handled. If you submit a value for the field, shouldn't it be true or false? If you want a null value as well you can always configure it as an enum and give it your options.