FilamentF
Filamentβ€’2y ago
RoccoW

Passing data to create page and filling form

Hi πŸ™‚
I have a relation manager (manages EventInstances on a EventResource) with a custom action in the header. My goal is to:
  1. Redirect the user to the create page of the EventInstanceResource
  2. Pass the owner record to the redirected page
  3. Fill a few form fields with data passed in the action
I managed the redirect, but I'm stuck trying to access the passed data. Here's the code I have so far:
public function table(Table $table): Table
    {
        return $table
            ->headerActions([
                Tables\Actions\Action::make('myAction')
                    ->action(function (RelationManager $livewire) {
                        $ownerRecord = $livewire->getOwnerRecord();
                        return redirect()->route('filament.admin.resources.event-instances.create',
                            [
                                'ownerRecord' => $ownerRecord,
                                'tenant' => Filament::getTenant(),
                            ]);
                    }),
            ])


How can I access the data on the create page? I have a property called $ownerRecord, but it only returns null.
P.S. I know a modal would probably be easier, but I perfer to open the form in a full page.
Was this page helpful?