Home » Database » DB_DataObject_FormBuilder » Bug #8698
Integers with NULL should be set to 'null'
Details
| Submitted | 2006-09-14 14:20 UTC |
|---|---|
| From | jw at php dot net |
| Assigned | justinpatrin |
| Status | Wont fix |
| Package | DB_DataObject_FormBuilder |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2006-09-14 14:20 UTC] jw at php dot net
Description:
------------
When I have an integer column which can be NULL in the database and I leave the generated formfield empty, the value is translated into the decimal 0. Actually this is done by DB_Dataobject in the methods insert() and update(). But if the formfield is empty it should be set to NULL. Right now I fix this in preProcessForm(&$values, &$fb) this way:
foreach ($this->table() as $field => $type) {
if ($type < DB_DATAOBJECT_NOTNULL && $type == DB_DATAOBJECT_INT) {
if (is_string($values[$field]) && strlen($values[$field]) == 0) {
$values[$field] = 'null';
}
}
}
I guess this should be done by FormBuilder automatically.