Problem with Reactive Searchable Select

Recently I started getting this weird error whenever I try to submit a form using this:
Forms\Components\Select::make('region')
->label('Province/State')
->disabled(static fn (callable $get) => $get('country') === null)
->options(static function (callable $get) {
$country = $get('country');

if (! $country) {
return [];
}

return Contact::getRegionOptions($country);
})
->searchable(static fn (Forms\Components\Select $component) => !$component->isDisabled()),
Forms\Components\Select::make('region')
->label('Province/State')
->disabled(static fn (callable $get) => $get('country') === null)
->options(static function (callable $get) {
$country = $get('country');

if (! $country) {
return [];
}

return Contact::getRegionOptions($country);
})
->searchable(static fn (Forms\Components\Select $component) => !$component->isDisabled()),
The callback inside the searchable() method is actually necessary in order for the form to be reactive when using disabled() (because searchable selects can't be disabled). Anyways, I recently started to get this weird error. Upon further investigation, the error does not occur when I remove the callback inside the searchable() method, which basically means I won't be able to have a reactive searchable Select unless I find the fix for this. This works and no error occurs:
Forms\Components\Select::make('region')
->label('Province/State')
->disabled(static fn (callable $get) => $get('country') === null)
->options(static function (callable $get) {
$country = $get('country');

if (! $country) {
return [];
}

return Contact::getRegionOptions($country);
}),
Forms\Components\Select::make('region')
->label('Province/State')
->disabled(static fn (callable $get) => $get('country') === null)
->options(static function (callable $get) {
$country = $get('country');

if (! $country) {
return [];
}

return Contact::getRegionOptions($country);
}),
Please help!
11 Replies
Kenneth Sese
Kenneth Sese13mo ago
Wonder if it’s related to this? Maybe when using disabled in conjunction with searchable it’s losing its wire:model? https://github.com/livewire/livewire/discussions/5600
GitHub
Str::studly() give back Too Few Arguments after update. · livewire ...
My project just updated to livewire version 2.12.2, and now it is randomly giving out this error: Too few arguments to function Illuminate\Support\Str::studly(), 0 passed in /home/tbsweb/sites/dyer...
Kenneth Sese
Kenneth Sese13mo ago
Also mentioned is duplicate ids and deferring/lazy conflicts.
Andrew Wallo
Andrew Wallo13mo ago
Yeah I saw that, but I'm not sure what I could do here to fix that. I saw wire:model would work instead of "wire:model.defer" or "wire:model.lazy", etc., but I think Reactive fields in Filament have to be lazy, defer, or debounce
Kenneth Sese
Kenneth Sese13mo ago
Is the wire:model blank or missing?
Andrew Wallo
Andrew Wallo13mo ago
Something to do with the entangle.defer with the state in all of Filament's components
Andrew Wallo
Andrew Wallo13mo ago
Andrew Wallo
Andrew Wallo13mo ago
It removes "data.state" and has a second syncInput on update
Kenneth Sese
Kenneth Sese13mo ago
Maybe because getStatePath() is returning null since it’s disabled? Might not be a way around that Maybe you could do what we had discussed some time back about using 2 selects and hiding one of them. This seems like an easier use case than before since you’re not trying to pass the value back and forth. But it does seem that the null name is the problem…same as what is mentioned in the GitHub issue
Andrew Wallo
Andrew Wallo13mo ago
Yeah it seems that way. Thanks It works with disabled method just not searchable though which is weird why it would remove the name of the record
Kenneth Sese
Kenneth Sese13mo ago
Seems like another one of those choices.js/livewire issues
Andrew Wallo
Andrew Wallo13mo ago
Possibly... I thought it was working recently but I suppose not idk Doing this worked out well for me, even though it’s a little weird and unorthodox to do 😂