Custom Input use masking. (Money)

Hello, I want to create a custom input for money values. I just want to move this mask to the MoneyInput class, so i have less repeating code. Do i need to change the getMask function in order to do this?

MoneyInput::make('total_income')
                                            ->label('Total Income')
                                            ->prefix('$')
                                            ->mask(fn (TextInput\Mask $mask) => $mask
                                                ->numeric()
                                                ->thousandsSeparator(',')
                                                ->decimalSeparator('.')
                                                ->decimalPlaces(2)
                                            )
                                            ->numeric()
                                            ->required(),


This doesn't work:
class MoneyInput extends TextInput
{
    public function getMask(): ?Mask
    {
        $mask = new Mask();

        $mask->numeric()
            ->thousandsSeparator(',')
            ->decimalSeparator('.')
            ->decimalPlaces(2);

        return $mask;
    }
}
Solution
Needed to add this and it apparently works. Thanks!
   public function hasMask(): bool
   {
       return true;
   }
Was this page helpful?