F
Filament15mo ago
*

Inserting pivot data without RelationManager

I have a multiple select on an edit page, has a belongsToMany() relationship. I want to inject something to be saved in a column in the pivot table. I found out that the relationship is saved in HasState::getState(), but could not find a way to inject additional data to it. Tried mutateFormDataBeforeSave() in the EditThing component, but that gets called after getState(), so no effect. Any help would be appreciated.
9 Replies
*
*OP15mo ago
Upping this in case it gets some attention on a Monday.
Patrick Boivin
Patrick Boivin15mo ago
Can you give an example of the kind of data you are trying to save to the pivot table? Do you think you could use a lifecycle hook like afterSave()?
*
*OP15mo ago
No description
*
*OP15mo ago
@pboivin does not help my case as it's called after getState
*
*OP15mo ago
GitHub
filament/packages/forms/src/Components/Concerns/BelongsToModel.php ...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
*
*OP15mo ago
This might just resolve my issue, I'm going to try and post here. Can confirm I can plug in and call my own action to save the relationship to inject additional data into the pivot row using saveRelationshipsUsing(function ($component, $state, $get)
*
*OP15mo ago
GitHub
Save CheckboxList with Pivot Attribute · filamentphp filament · Dis...
Hi, Is there a way to save a CheckboxList with a Pivot Attribute? Say I have three tables event dance style and a pivot table where style_id is the pivot attribute event_dance -event_id -dance_id -...
*
*OP15mo ago
This was helpful Wish it was discoverable via the docs.
Want results from more Discord servers?
Add your server