ariaieboy / filament-currency

Enhanced Currency Related stuff for Filament
MIT License
42 stars 8 forks source link

[Bug]: Default value 0 is not supported #38

Closed quinleys closed 3 months ago

quinleys commented 3 months ago

What happened?

When adding default value 0 to a TextInput with currencyMask added the field is just empty instead of showing 0.

\Filament\Forms\Components\TextInput::make('full_commission_amount') ->numeric() ->readOnly() ->disabled() ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 2) ->label('100 % Commissie Bedrag') ->prefix('€') ->minValue(0) ->default(0) ->live(),

CleanShot 2024-06-08 at 18 09 22@2x

How to reproduce the bug

See 'What happened'

Package Version

2

PHP Version

8.2

Laravel Version

11.4

Which operating systems does with happen with?

No response

Notes

No response

ariaieboy commented 3 months ago

what is the exact package version that you use? we don't have version 2 🙃

ariaieboy commented 3 months ago

I can't reproduce this bug. When the default value is set to 0 in the create page it's get populated without any problem. In the edit page it's not getting loaded but that's not related to our package if you create a simple TextInput in the edit page the default value is not getting populated.

ariaieboy commented 3 months ago

According to the doc https://filamentphp.com/docs/3.x/forms/fields/getting-started#setting-a-default-value That's intentional behavior. the default value only works if the form is not getting filled from the model, thus creating a page.