From 02ee7f3721445a8e5535ec79f3eb30a98e2908d2 Mon Sep 17 00:00:00 2001 From: robertall Date: Tue, 27 May 2008 07:43:14 +0000 Subject: [PATCH] [MDL-14788] Don't store empty number fields as 0 --- mod/data/field/number/field.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/data/field/number/field.class.php b/mod/data/field/number/field.class.php index 073a091ad6b68..fa3bc07a9a42a 100755 --- a/mod/data/field/number/field.class.php +++ b/mod/data/field/number/field.class.php @@ -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;