Preload Multi Select values [solved]

Hi I have a Job Profile Resource which has a many-to-many relationship with my certifications resource. When creating a job Profile, I want to user to see the list of available values for certification and choose from it. But when the certification field is of type multi-select, filament is making me search for each value. I got a suggestion from the chat to look into preloadrecordselect() but when I use it in my code its erroring if the input type is multi select. Can anyone help pls? https://gist.github.com/mahesh13614/4e7b446a62e4cb3dadfea42501294af4
Gist
Need Certification to be a multiselect picklist.
Need Certification to be a multiselect picklist. . GitHub Gist: instantly share code, notes, and snippets.
9 Replies
Mark Chaney
Mark Chaney2y ago
@booboomonster are you using and IDE? Have you looked at the docs at all for selects? MultiSelect had been depreciated for ages as well
Mark Chaney
Mark Chaney2y ago
Filament
Fields - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
toodles
toodlesOP2y ago
I usually learn better by following boilerplate code posted by others maybe the one I i was getting this from was outdated. Thanks for pointing it out, I am going to try this.
Mark Chaney
Mark Chaney2y ago
Lots of examples in the docs 🙂
toodles
toodlesOP2y ago
Thanks I added ->options([ AssociateAction::make()->preloadRecordSelect() as mentioned in the doc and the drop down mode seems to have activated, but is returning literally one value [object Object]. I am looking into it, but if you can point at what I might be missing id appreciate it.
Dan Harrin
Dan Harrin2y ago
if you can send the code for the select with the object Object we can help
toodles
toodlesOP2y ago
Thanks ...return $form ->schema([ Forms\Components\TextInput::make('title')->label('Title')->required(), Forms\Components\Select::make('certifications') ->multiple() ->label('Certifications') ->relationship('certifications', 'name') ->options([ AssociateAction::make()->preloadRecordSelect() I think I need to catch it as an array then display but not sure how to. Thanks for your help.
Dan Harrin
Dan Harrin2y ago
thats definitely not right why are you passing an action into the options()?
toodles
toodlesOP2y ago
that prod was what I needed, thanks got it to work with this. >schema([ Forms\Components\TextInput::make('title')->label('Title')->required(), Forms\Components\Select::make('certifications') ->multiple() ->label('Certifications') ->relationship('certifications', 'name') ->preload(),

Did you find this page helpful?