Skip to content

Commit

Permalink
Merge + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pelmered committed Jan 31, 2024
1 parent ba62c62 commit b44a597
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Forms/Components/MoneyInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ protected function setUp(): void
{
parent::setUp();


$this->inputMode('decimal');
$this->rule('numeric');
$this->step(0.01);
$this->minValue = 0;


$this->formatStateUsing(function (MoneyInput $component, $state): ?string {

$this->prepare($component);

return is_null($state) ? null : MoneyFormatter::decimalToMoneyString($state / 100, $component->getLocale());
if (is_null($state)) {
return '';
}
if(!is_numeric($state)) {
return $state;
}

return MoneyFormatter::decimalToMoneyString($state / 100, $component->getLocale());
});

$this->dehydrateStateUsing( function (MoneyInput $component, $state): string {
$this->dehydrateStateUsing(function (MoneyInput $component, $state): string {

$this->prepare($component);

Expand All @@ -50,5 +54,7 @@ protected function prepare(MoneyInput $component): void
}

$this->stripCharacters($formattingRules->groupingSeparator);
// OR
$this->stripCharacters([',', '.', ' ',]);
}
}

0 comments on commit b44a597

Please sign in to comment.