MDL-80858 customfield_number: new field type for numeric data.
Provide field type to allow for number type data to be stored and presented within those components that already support custom fields. This is especially useful for reporting purposes.
This commit is contained in:
@@ -200,8 +200,15 @@ abstract class data_controller {
|
||||
if (!property_exists($datanew, $elementname)) {
|
||||
return;
|
||||
}
|
||||
$value = $datanew->$elementname;
|
||||
$this->data->set($this->datafield(), $value);
|
||||
$datafieldvalue = $value = $datanew->{$elementname};
|
||||
|
||||
// For numeric datafields, persistent won't allow empty string, swap for null.
|
||||
$datafield = $this->datafield();
|
||||
if ($datafield === 'intvalue' || $datafield === 'decvalue') {
|
||||
$datafieldvalue = $datafieldvalue === '' ? null : $datafieldvalue;
|
||||
}
|
||||
|
||||
$this->data->set($datafield, $datafieldvalue);
|
||||
$this->data->set('value', $value);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user