PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject_FormBuilder » Bug #8698

Integers with NULL should be set to 'null'

Details

Submitted2006-09-14 14:20 UTC
Fromjw at php dot net
Assignedjustinpatrin
StatusWont fix
PackageDB_DataObject_FormBuilder
PHP VersionIrrelevant
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.