[MDL-14788] Don't store empty number fields as 0

This commit is contained in:
robertall 2008-05-27 07:43:14 +00:00
parent bfc59a6763
commit 02ee7f3721

View File

@ -34,7 +34,12 @@ class data_field_number extends data_field_base {
$content = new object;
$content->fieldid = $this->field->id;
$content->recordid = $recordid;
$content->content = (float)$value;
$value = trim($value);
if (strlen($value) > 0) {
$content->content = floatval($value);
} else {
$content->content = null;
}
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;