Relation Manager create record using Resource page instead of modal

Jun 2, 2022
Admin panel

The default behaviour when hitting the Create button on the Relation Manager is for the new record form to be displayed in a modal.

Sometimes that related record may be a little big or cumbersome to be handled in a modal and it may be quicker or simpler to redirect and create the record using the Resource's Create page.

Let's say we have a Customer Resource with an InvoiceRelationManager.

First we need to use the CreateAction() on the InvoiceRelationManager

use Filament\Tables\Actions\CreateAction;
->url(fn ($livewire) => InvoiceResource::getUrl('create', ['ownerRecord' => $livewire->ownerRecord->getKey()]))

Note that we pass in the calling customer's record key as a query param to our URL ['ownerRecord' => $this->ownerRecord->getKey()]

We can now pre-populate the Customer BelongsToSelect on the InvoiceResource


Et voila!


Nice 👌


I got "Using $this when not in object context"

any idea? thanks


btw, another workaround is get the key from url request()->segment(3)