F
Filament14mo ago
Remi

Get in ->maxItems() doesnt work

I've got a multi-select form field, in which the user can select 1 or 5 items, based on previous select.
Forms\Components\Select::make('status')
->required()
->options(StatusEnum::collect()->translate())
->live(),

Forms\Components\Select::make('locations')
->translateLabel()
->multiple()
->preload()
->relationship('locations', 'name')
->required()
->maxItems(fn(Get $get) => $get('status') > StatusEnum::ALMOST_MOVING ? 1 : 5)
Forms\Components\Select::make('status')
->required()
->options(StatusEnum::collect()->translate())
->live(),

Forms\Components\Select::make('locations')
->translateLabel()
->multiple()
->preload()
->relationship('locations', 'name')
->required()
->maxItems(fn(Get $get) => $get('status') > StatusEnum::ALMOST_MOVING ? 1 : 5)
The status field is updated correctly, but the maxItems always stays the initial value. It isnt updated. Is this a bug? or am i doing something wrong?
2 Replies
toeknee
toeknee14mo ago
I would dd on status and statusEnum to check what it receives.
Remi
RemiOP14mo ago
I added a new field to debug it, and added an afterStateUpdated on the status field, and made it set the text field to the value. It updates correctly. the value is an int just like the enum is in this case
Want results from more Discord servers?
Add your server