mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
[MDL-14788] Don't store empty number fields as 0
This commit is contained in:
parent
bfc59a6763
commit
02ee7f3721
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user