Skip to content

Commit

Permalink
[MDL-14788] Don't store empty number fields as 0
Browse files Browse the repository at this point in the history
  • Loading branch information
robertall committed May 27, 2008
1 parent bfc59a6 commit 02ee7f3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mod/data/field/number/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ function update_content($recordid, $value, $name='') {
$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;
Expand Down

0 comments on commit 02ee7f3

Please sign in to comment.