F
Filamentβ€’9mo ago
ericmp

How to make TextInput accept only 2 decimals

The price must only contain 2 decimals
Forms\Components\TextInput::make('price')
->numeric()
->inputMode('numeric')
->minValue(0.01)
->step(0.01)
->required()
->suffixIcon('heroicon-m-currency-euro')
,
Forms\Components\TextInput::make('price')
->numeric()
->inputMode('numeric')
->minValue(0.01)
->step(0.01)
->required()
->suffixIcon('heroicon-m-currency-euro')
,
But when i try it out, i can write several decimals. What i am missing?
No description
3 Replies
bwurtz999
bwurtz999β€’9mo ago
I'm not sure there is a way to limit the decimal places directly. You could use ->afterStateUpdated(function ($state, $set) and $set the value of the field to a rounded value
ericmp
ericmpOPβ€’9mo ago
like this works, but i want it to be formatted like this: 1.500,40 but i get: 1,500.40 i guess at the moment doesnt accept localisation or idk how to set it up now im trying this πŸ‘€
Want results from more Discord servers?
Add your server