TextInput is not updates when mask active

Hi, I have 2 TextInput in my form. When i update first input, it updates second input with some calculations. But after i add mask to input it not updates anymore. Here is my code:
TextInput::make('producer_price')
->suffix('TL')
->label(__('product::filament.producer_price'))
->default(0)
->reactive()
->afterStateUpdated(function (\Closure $get, \Closure $set) {
self::calculatePrices($get, $set);
})
->lazy()
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->decimalPlaces(2)
->decimalSeparator(',')
->mapToDecimalSeparator([','])
->minValue(1)
->maxValue(PHP_INT_MAX)
->normalizeZeros()
->padFractionalZeros()
->thousandsSeparator('.'),
),
TextInput::make('net_producer_price')
->label(__('product::filament.net_producer_price'))
->suffix('TL')
->default(0)
->required()
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->decimalPlaces(2)
->decimalSeparator(',')
->mapToDecimalSeparator([','])
->minValue(1)
->maxValue(PHP_INT_MAX)
->normalizeZeros()
->padFractionalZeros()
->thousandsSeparator('.'),
),
TextInput::make('producer_price')
->suffix('TL')
->label(__('product::filament.producer_price'))
->default(0)
->reactive()
->afterStateUpdated(function (\Closure $get, \Closure $set) {
self::calculatePrices($get, $set);
})
->lazy()
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->decimalPlaces(2)
->decimalSeparator(',')
->mapToDecimalSeparator([','])
->minValue(1)
->maxValue(PHP_INT_MAX)
->normalizeZeros()
->padFractionalZeros()
->thousandsSeparator('.'),
),
TextInput::make('net_producer_price')
->label(__('product::filament.net_producer_price'))
->suffix('TL')
->default(0)
->required()
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->decimalPlaces(2)
->decimalSeparator(',')
->mapToDecimalSeparator([','])
->minValue(1)
->maxValue(PHP_INT_MAX)
->normalizeZeros()
->padFractionalZeros()
->thousandsSeparator('.'),
),
Calculate prices method does some calculations it's working but i set values like this:
$set('net_producer_price', $prices['net_producer_price']);
$set('net_producer_price', $prices['net_producer_price']);
4 Replies
OzgurOzarpaci
OzgurOzarpaciOP16mo ago
I searched and Mask doesn't allows reactivity. So, don't use mask if you have dependant inputs.
Veggigit
Veggigit13mo ago
Could you have information about this?
OzgurOzarpaci
OzgurOzarpaciOP13mo ago
When you use mask, you can't use reactivity. They added this in documentation
Veggigit
Veggigit13mo ago
thx for u answer
Want results from more Discord servers?
Add your server