ariaieboy / filament-currency

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

[Bug]: Error casting int column database #5

Closed danielreales7 closed 1 year ago

danielreales7 commented 1 year ago

What happened?

I am working with a TextInput where I want to display the price in EUR, and the value coming from the database is of integer type. When I apply ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 2), it gives me an error in the console: image

I'm using this casting:

https://filamentphp.com/docs/3.x/panels/getting-started#casting-the-price-to-an-integer

How to reproduce the bug

TextInput::make('price') ->required() ->numeric() ->suffix('€') ->currencyMask(thousandSeparator: '.',decimalSeparator: ',',precision: 2)

Package Version

1.1.1

PHP Version

8.1

Laravel Version

10.10

Which operating systems does with happen with?

macOS

Notes

No response

danielreales7 commented 1 year ago

If I delete the casting that I created the TextColumn works fine for me: TextColumn::make('price')->label('Precio')->currency('EUR') but TextInput have the same error in console. I'm testing in Chrome

ariaieboy commented 1 year ago

@danielreales7, can you create a public repo that reproduces this bug so I can investigate the problem?

danielreales7 commented 1 year ago

@ariaieboy https://github.com/danielreales7/test-filament-currency I create a new project for this with a seeder.

Thank you so much for your help!

danielreales7 commented 1 year ago

@ariaieboy I was doing some testing, and of course, the input is of integer type, so when applying replaceAll, it gives that error. In case it were a string, it would work correctly. I made this example: init(){ let formattedNumber = (this.input / 100).toLocaleString('es-ES'); this.masked = formattedNumber.replaceAll('.','$decimalSeparator'); \$watch('masked',()=>this.updateInput()); }, And it works correctly.

ariaieboy commented 1 year ago

@danielreales7 test version 1.1.2, the problem should be fixed

danielreales7 commented 1 year ago

Hi @ariaieboy

I'm getting same error:

image

replaceAll for number input it's not possible.

ariaieboy commented 1 year ago

Hi @ariaieboy

I'm getting same error:

image

replaceAll for number input it's not possible.

can you test it in your repo and reproduce this error on that? https://github.com/danielreales7/test-filament-currency

ariaieboy commented 1 year ago

fixed in 1.1.3