How do I disable the Auto-saving of Form field relationships?

I currently have a form similar to the following:
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('General')
->schema([
Forms\Components\Select::make('account_id')
->label('Account')
->relationship('account', 'name')
->searchable()
->preload()
->nullable(),
Forms\Components\Select::make('currency_code')
->label('Currency')
->relationship('currency', 'code')
->searchable()
->preload()
->nullable(),
])->columns(),
// More fields...
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('General')
->schema([
Forms\Components\Select::make('account_id')
->label('Account')
->relationship('account', 'name')
->searchable()
->preload()
->nullable(),
Forms\Components\Select::make('currency_code')
->label('Currency')
->relationship('currency', 'code')
->searchable()
->preload()
->nullable(),
])->columns(),
// More fields...
]);
}
The entire form has around 8 fields that all have a relationship. The only issue is that it is absolutely necessary that I use the handleRecordUpdate() method to further handle the data and record being saved. I honestly think that it should be mentioned in the documentation that Filament will automatically save the data before you can handle it any further within the handleRecordUpdate() method since this may cause Users confusion. But anyways, is there a way to disable the auto saving of relationships for the entire form? I am aware that I could do this for each field:
Forms\Components\Select::make('currency_code')
->label('Currency')
->relationship('currency', 'code')
->saveRelationshipsUsing(null) // Here
->searchable()
->preload()
->nullable(),
Forms\Components\Select::make('currency_code')
->label('Currency')
->relationship('currency', 'code')
->saveRelationshipsUsing(null) // Here
->searchable()
->preload()
->nullable(),
But I find this a little exhaustive.
2 Replies
Mikazor
Mikazor7mo ago
@Andrew Wallo do you solve it?
Andrew Wallo
Andrew Wallo7mo ago
Nope. I just had to keep using “saveRelationshipsUsing()”