© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo ago•
4 replies
Mikavdwiel

Edit action on RelationManager with pivot redirects to linked Model instead (using pivot's ID)

Hi,

I have a relation manager that edits a many-to-many relation with pivot values. The table nicely displays these pivot values and i am able to set these pivot values on the attach action with a custom form.

Now i wish to have an edit action to edit these pivot values. The documentation states if the relations are set up correctly, the edit action will edit the pivot values.

My relations seems to be set up correctly, and as stated, the table and attach are working properly. However, the edit action redirects to the resource the many-to-many relation is linked to using the id of the pivot entry... So i get a 404.

It feels like a V4 issue.

If it helps, here is my relation manager's table:
        return $table
            ->columns([
                TextColumn::make('name')->searchable(),
                TextColumn::make('label')->label('Label'),
                TextColumn::make('position_x')->label('Position X'),
                TextColumn::make('position_y')->label('Position Y'),
            ])
            ->allowDuplicates()
            ->actions([
                EditAction::make(),
                DetachAction::make(),
            ])
            ->headerActions([
                AttachAction::make()
                    ->multiple()
                    ->recordTitle(fn (Model $record): string => "{$record->name}")
                    ->recordSelectSearchColumns(['name', 'description'])
                    ->schema(fn (AttachAction $action): array => [
                        $action->getRecordSelect(),
                        TextInput::make('position_x')->numeric(),
                        TextInput::make('position_y')->numeric(),
                        TextInput::make('label'),
                    ])
            ]);
        return $table
            ->columns([
                TextColumn::make('name')->searchable(),
                TextColumn::make('label')->label('Label'),
                TextColumn::make('position_x')->label('Position X'),
                TextColumn::make('position_y')->label('Position Y'),
            ])
            ->allowDuplicates()
            ->actions([
                EditAction::make(),
                DetachAction::make(),
            ])
            ->headerActions([
                AttachAction::make()
                    ->multiple()
                    ->recordTitle(fn (Model $record): string => "{$record->name}")
                    ->recordSelectSearchColumns(['name', 'description'])
                    ->schema(fn (AttachAction $action): array => [
                        $action->getRecordSelect(),
                        TextInput::make('position_x')->numeric(),
                        TextInput::make('position_y')->numeric(),
                        TextInput::make('label'),
                    ])
            ]);


The Connector assembly has a many to many relationship with a component. The edit action is redirecting to a component with the id of the pivot. While i want it to edit the pivot values in a modal (like the documentation states).
Solution
Add a custom action to update the pivot data:

Action::make('updatePositions')
    ->fillForm(fn (Model $record) => $record->attributesToArray())
    ->schema([
        TextInput::make('position_x'),
    ])
    ->action(function (array $data, Model $record) {
        $record->pivot->position_x = $data['position_x'];
        $record->pivot->save();
    })
Action::make('updatePositions')
    ->fillForm(fn (Model $record) => $record->attributesToArray())
    ->schema([
        TextInput::make('position_x'),
    ])
    ->action(function (array $data, Model $record) {
        $record->pivot->position_x = $data['position_x'];
        $record->pivot->save();
    })
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Edit RelationManager pivot array data
FilamentFFilament / ❓┊help
12mo ago
Cast Problem on Pivot table together with RelationManager
FilamentFFilament / ❓┊help
3y ago
Display table action when using RelationManager on ViewRecord
FilamentFFilament / ❓┊help
3y ago