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:
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:Jump to solution
Add a custom action to update the pivot data:
```php
Action::make('updatePositions')
->fillForm(fn (Model $record) => $record->attributesToArray())...
2 Replies
Solution
Add a custom action to update the pivot data:
Massive thanks, this is working!
Does this allso mean i was wrong about the many-to-many relation auaotmatically editing the pivot when one is set? because the default edit action was pointing to a non-existing resource, so it does seem like I, or fillament did something wrong...