$livewire->form->fill() doesn't work when using slideOver()

I've been following Kevin McKee's excellent "Rapid Laravel Apps with Filament" Laracast but run into an issue when trying to use a factory to fill a form (for testing purposes).

When my resource ("Campaign") has a dedicated CreateCampaign route/page, I'm able to add an action to the form as follows:

Actions::make([
                    Action::make('star')
                        ->label('Insert test data')
                        ->icon('heroicon-m-pencil-square')
                        ->visible(function (string $operation) {
                            return $operation === 'create' && app()->environment('local');
                        })
                        ->action(function (Livewire $livewire) {
                            $data = Campaign::factory()->make()->toArray();
                            $livewire->form->fill($data);
                        }),
                    ])


and this works great. However, I'd prefer to use the slideOver() so I comment out 'create' => Pages\CreateCampaign::route('/create'), in the getPages() function of the campaign resource and add ->slideOver() to the getHeaderActions of the ListCampaigns file (no other changes made).

I then get the following error:

Filament\Resources\Pages\ListRecords::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given, called in /Users/joe/Projects/test_system/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 56

It looks like, when using a slideOver, $livewire is the ListCampaign component rather than the CreateCampaign page so the form is not accessible through $livewire->form. I'm sure there is an easy workaround but I'm pretty new to all this. Thanks 🙂
Was this page helpful?