Multi select selected issue

In twill3 I created 2 CRUD, ImportedItem and ItemTypes. I used Multiselect for selecting ItemTypes. $form->add( MultiSelect::make() ->name('item_types_id') ->label('Item Type') ->inline() ->options( Options::make( ItemType::all() ->map( fn($sector) => Option::make( $sector->id, $sector->title ) ) ->toArray() ) ) ); This is the code. I also tried another code also $form->add( MultiSelect::make() ->inline() ->name('item_types_id') ->label('Item Type') ->searchable() ->options( app()->make(ItemTypeRepository::class)->listAll()->toArray() ) ); Here updated on pivot table. But after refresh its not selected. How do I selected this in multiselect?
No description
No description
No description
1 Reply
ifox
ifox11mo ago
Hi @Somnath a multi select between 2 models needs a pivot table and associated eloquent relationships, did you set that up?
Want results from more Discord servers?
Add your server