From 94082c17eafac82b5bad5f49791fa0e23fcf7cdc Mon Sep 17 00:00:00 2001 From: Demian Ottema <44736169+demianottema@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:54:48 +0200 Subject: [PATCH] Added fix for empty stings in a query (pelmered/filament-money-field#18) --- src/Forms/Components/MoneyInput.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Forms/Components/MoneyInput.php b/src/Forms/Components/MoneyInput.php index af9242a..7e262e7 100644 --- a/src/Forms/Components/MoneyInput.php +++ b/src/Forms/Components/MoneyInput.php @@ -35,13 +35,14 @@ protected function setUp(): void return MoneyFormatter::formatAsDecimal($state, $currency, $locale); }); - $this->dehydrateStateUsing(function (MoneyInput $component, $state): string { - + $this->dehydrateStateUsing(function (MoneyInput $component, $state): ?string { $currency = $component->getCurrency(); $state = MoneyFormatter::parseDecimal($state, $currency, $component->getLocale()); - $this->prepare(); - + if (empty($state)) { + return null; + } + return $state; }); }