From 579c2ae68be36eb0a6cea472b680333ba914b68e Mon Sep 17 00:00:00 2001 From: Alex Deniz Garcia Date: Tue, 29 Aug 2023 13:19:04 +0200 Subject: [PATCH] REV-12275: make decimal field nullable --- src/Fields/Decimal.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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';