Conditional Selectors take too long to load, or fail to load
Hello,
I'll be providing the code that I'm using to load a selector based on another one,
It's not generating errors, but it doesn't load sometimes, leading the second selection to always be raw,
14 Replies
here is the code
second table contains too much rows in the db, defeats 3000
try adding
->searchable()
and ->preload()
WORKED LIKE MAGIC β¨
is there anyway I also make it searchable on another attribuute?
of that entity I mean
just add it to the option
to the child object
should work
thank you 2 magician @Lara Zeus
how is that?
Forms\Components\Select::make('wilaya')
->options(
Wilaya::all()->pluck('designation', 'id')
)
->required()
->afterStateUpdated(fn(callable $set) => $set('commune', null)),
Forms\Components\Select::make('commune')
->options(
function (callable $get) {
$wilaya = Wilaya::find($get("wilaya"));
if (!$wilaya) {
return [];
}
return $wilaya->commune->pluck('nomCommune', 'id');
}
)->searchable()
see if thqat works
ahh, so thatt's gonna make it exist twice right?
explore and see π
what I meant was:
I'm only plucking the nomCommune, which is the name,
is there anyway I could make the search include the id, that is in the db
but seeing how this is functionning, the logic seems wrong, this returns only names, so yeah,
pluck('name','id')
works but makes it only for the id,
well, I think it's already a weird idea,
to search on both, name, or the id if needed
Select::make('author_id')
->relationship(name: 'author', titleAttribute: 'name')
->searchable(['name', 'email'])
this way you can .. across multiple fields
maybe it's me, but it somehow provoked something like: the search doesn't work
I mean it doesn't do what I needed it to do,
but also the search became global! which isn't somthI want
I'll look it up more later, maybe I just rushed it