How Can I Stop the Relationship from Auto-Saving After Submitting the Form
Hello everyone, basically I just want to retrieve the data from a form and save it as a JSON object in the database after the user submits the form. However, due to the relationship relationship(name: 'services', titleAttribute: 'name'), the pivot table is automatically updated after submitting the form. How can I stop this?
Thank you!
2 Replies
If you want to save it manually, add
dehydrated()
in the repeater after relationship()
Table Action :
Tables\Actions\EditAction::make()
->before(function (array $data, Domain $record, $action): array {
dd($record->services);
}); Inside the From : Select::make('services')->native(false)->preload() ->helperText(fn (Get $get, $livewire) => renderHelperTextDomainForm::renderHelperTextForInactiveServices($livewire, $get('services'))) ->relationship(name: 'services', titleAttribute: 'name') ->dehydrated() I really don't know what I'm doing wrong, after the dd($record->services) is launched the services record is already has been updated in the db !
}); Inside the From : Select::make('services')->native(false)->preload() ->helperText(fn (Get $get, $livewire) => renderHelperTextDomainForm::renderHelperTextForInactiveServices($livewire, $get('services'))) ->relationship(name: 'services', titleAttribute: 'name') ->dehydrated() I really don't know what I'm doing wrong, after the dd($record->services) is launched the services record is already has been updated in the db !