Update TextInput maxValue
Hi friends.
How we can use ->afterStateUpdated to change another TextInput maxValue?
6 Replies
Not sure but I think max value can support a closure. You could try going through a public property on your Page component:
Thank you ,
I checked and this is result:
Property [$myMaxValue] not found on component
are you trying to do something like this?
Forms\Components\Select::make('variation_id')
->options(Variation::query()->where('inventory', '>' , 0)->pluck('title', 'id'))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->id} {$record->title} {$record->id}")
->required()
->reactive()
->afterStateUpdated(function ($state, Forms\Set $set, Forms\Get $get) {
if($v = Variation::find($state)) {
// I need to set maxValue of quantity to $v->inventory;
}
})
->columnSpan([
'md' => 3,
])
->searchable(),
Forms\Components\TextInput::make('quantity')
->label('Quantity')
->numeric(),
same logic
Thank you bro. ✅