Set number fields to null if no value entered

This commit is contained in:
flynsarmy 2014-09-13 18:29:10 +10:00
parent 8dcef0ebfb
commit 60958efeed
1 changed files with 3 additions and 1 deletions

View File

@ -706,7 +706,9 @@ class Form extends WidgetBase
$columnParts = Str::evalHtmlArray($field->columnName);
$columnDotted = implode('.', $columnParts);
$columnValue = array_get($data, $columnDotted, 0);
if ($field->type == 'number') $columnValue = (float) $columnValue;
if ($field->type == 'number') {
$columnValue = !strlen(trim($columnValue)) ? NULL : (float) $columnValue;
}
array_set($data, $columnDotted, $columnValue);
}