Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aarontharker's avatar

Change the resource opened by the edit action of a relation manager

This is going to get confusing but let me try. I have 2 models Degree and Programs, these share a many to many relationship that includes pivot table data. These tables are also accessed from a different (legacy) application so the pivot table needed to have it's own id field. So I made a model and resource in filament called DegreeProgram. I have setup the forms etc for DegreeProgram in filament but it looks ugly having it on the navigation menu.

Within the DegreeResource I have a relationmanager for programs and would like to have the create and edit actions from that relation manager redirected to the create and redirect forms for the DegreeProgramResource instead, while leaving the attach/deteach actions link the the original relationship.

I tried editing the relationship manager to use the other form but that threw this error Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given.

So then I tried mutating the data being sent to the form like this

->mutateRecordDataUsing(fn (array $data): array => [
             $data = DegreeProgram::where('program_id', $data['program_id'])->where('degree_id', $data['degree_id'])->first(),
         ]),

but that throws this error Call to a member function getResults() on null

0 likes
1 reply
aarontharker's avatar
aarontharker
OP
Best Answer
Level 2

So rather than customizing the predefined edit to suit my needs I created a custom edit action to replace it.

Please or to participate in this conversation.