F
Filamentβ€’3mo ago
Soundmit

Dependant select in modal form

hi have my main form, from here i have 2 selects one for Brand and one for Item when i select the Brand (for example Roland) i have the Item select populated with all the Roland instruments but i can also create new Instrument from here. A modal form is opened and i create the instrument Now the difficult part I want this behaviour - select the brand in the main form (ok) - open the modal for creating a new instrument (ok) - here i have this fields: name, model, BRAND, type BRAND should be pre-populated with the brand selected in the main form The code (attached) ```
Solution:
->default(fn ($livewire) => $livewire->data['brand_id'])
->default(fn ($livewire) => $livewire->data['brand_id'])
...
Jump to solution
7 Replies
Soundmit
Soundmitβ€’3mo ago
i have this line ->default(fn (Livewire $livewire) => $livewire->data['brand_id']) but it doesnt works i get this error

App\Filament\Resources\RepairResource::App\Filament\Resources\{closure}(): Argument #1 ($livewire) must be of type Filament\Forms\Components\Livewire, App\Filament\Resources\RepairResource\Pages\CreateRepair given, called in /var/www/

App\Filament\Resources\RepairResource::App\Filament\Resources\{closure}(): Argument #1 ($livewire) must be of type Filament\Forms\Components\Livewire, App\Filament\Resources\RepairResource\Pages\CreateRepair given, called in /var/www/
on top i have use Filament\Forms\Components\Livewire;
Soundmit
Soundmitβ€’3mo ago
No description
Soundmit
Soundmitβ€’3mo ago
No description
Soundmit
Soundmitβ€’3mo ago
No description
Soundmit
Soundmitβ€’3mo ago
should be
No description
Solution
toeknee
toekneeβ€’3mo ago
->default(fn ($livewire) => $livewire->data['brand_id'])
->default(fn ($livewire) => $livewire->data['brand_id'])
Soundmit
Soundmitβ€’3mo ago
Thanks! It works!!! πŸ™‚