Home » Database » DB_DataObject_FormBuilder » Bug #3164
Use of DB_DataObject_Cast use should be removed or optional
Details
| Request #3164 | Use of DB_DataObject_Cast use should be removed or optional |
|---|---|
| Submitted | 2005-01-11 16:02 UTC |
| From | ate2 at cornell dot edu |
| Assigned | justinpatrin |
| Status | Bogus |
| Package | DB_DataObject_FormBuilder |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-01-11 16:02 UTC] ate2 at cornell dot edu
Description:
------------
As far as I can tell, DB_DataObject_Cast is used only twice in the class and in both cases it is used to pass an sql NULL. This seems unnecessary since DB_DataObject already sets fields to null if they are allowed to be null, have no default value (determined by db backend), and return a false when passed through the isset() method (not set or are set to php null). Unless there are specific situations where this casting would be necessary, I'd propose removing casting altogether. Otherwise, maybe another class property to allow disabling cast.
Reproduce code:
---------------
$do =& new DB_DataObject();
$fb =& new DB_DataObject_FormBuilder($do);
$form =& $fb->getForm();
if ($form->validate()) {
$do->processForm();
if (empty($do->field)) {
echo "Field is not set.";
}
else {
echo "Field is set to value {$do->field}.";
}
}
echo $form->toHtml();
Expected result:
----------------
"Field is not set."
Actual result:
--------------
"Field is set to value Object."