Modify query on AttachAction

Hello,

I have this code, allowing to attach more products with BelongsToMany Relation:
    Tables\Actions\AttachAction::make()
                    ->preloadRecordSelect()
                    ->form(fn(Tables\Actions\AttachAction $action): array => [
                        $action->getRecordSelect()->required(),
                        Forms\Components\ColorPicker::make('color')
                            ->required()
                    ])


It works, but I want to modify the query when saving, to add the inverse record in the DB, how do your do that ?


Tried $action->getRecordSelect()->saveRelationshipsUsing, but since it doesnt have ->relationship chained it doesnt work.

Is there any way to do this, event if its not trough filament?

Thanks!
Was this page helpful?