Decimal separator to comma instead of dot

Hey all, In my country we use comma as a decimal separator instead of a dot. So I would like to ask: how to change de price display/input to get and set with a comma as a decimal separator? Doing this on a resource level with masks for input transformation seem like an overkill. Thanks!
5 Replies
K R A T O S
K R A T O S16mo ago
TextInput::make('total')
->placeholder('00000.00')
->prefix('£')
->mask(RawJs::make(
<<<'JS'
$money($input, '.', ',', 2)
JS
)),
TextInput::make('total')
->placeholder('00000.00')
->prefix('£')
->mask(RawJs::make(
<<<'JS'
$money($input, '.', ',', 2)
JS
)),
$money($input, '.', ',', 2) this is the main part. You can specify it to be whatever you want
Diogo Pinto
Diogo PintoOP16mo ago
@K R A T O S thank you for your input, but I'll have to adapt this logic to a bunch of forms and tables. I thought that maybe there could be a cast or mutator on the Model level that could affect this. In Europe it's really common to have comma as a separator *decimal separator
K R A T O S
K R A T O S16mo ago
I mean, You could do it with simple string manipulation as well, But if you want filament's text input to give you the currency in a specific format, this is the filament way to do it.
Diogo Pinto
Diogo PintoOP16mo ago
Thank you @K R A T O S . This isn't a currency use case, but clinical information for calculations. So, using string manipulation affect the calculation possibility and leads to more logic behind the scenes Thanks for your input though!
Want results from more Discord servers?
Add your server