diff --git a/src/Fields/Decimal.php b/src/Fields/Decimal.php index a439f12b..92c69a93 100644 --- a/src/Fields/Decimal.php +++ b/src/Fields/Decimal.php @@ -5,11 +5,15 @@ class Decimal extends Text { protected $asInteger = false; + protected $nullable = false; public $rowClass = 'text-right'; public function getValue($object) { $value = parent::getValue($object); + if ($value === null & $this->nullable) { + return null; + } if ($value && $this->asInteger) { return number_format(floatval($value) / 100.0, 2); } @@ -30,6 +34,12 @@ public function asInteger($asInteger = true) return $this; } + public function nullable($nullable = true) + { + $this->nullable = $nullable; + return $this; + } + protected function getFieldType() { return 'number';