mutateFormDataBeforeCreate question

I want to send an API request before I store data in my DB so I use mutateFormDataBeforeCreate in my relevant Create Record page. Is it the most suitable way to interrupt the saving process ? I noticed that
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
return $data;
}
Select::make('sshKeys')
->multiple()
->relationship('sshKeys', 'name')
->required()
->preload()
->label('SSH Key'),
Select::make('sshKeys')
->multiple()
->relationship('sshKeys', 'name')
->required()
->preload()
->label('SSH Key'),
When I try to get the data I cannot see the multi select data that are in a many to many relationship. Do you know why? Thanks!
5 Replies
awcodes
awcodes12mo ago
Try $this->form->getRawState() without validation and $this->form->getState() with validation.
Theodoros
TheodorosOP12mo ago
It worked with $this->form->getRawState(). Thanks!
awcodes
awcodes12mo ago
Just be cautious. That data hasn’t been validated.
Theodoros
TheodorosOP12mo ago
Is this a good way to interrupt the creating process to send the API call to an external service?
awcodes
awcodes12mo ago
As good as any I guess. There’s nothing inherently wrong with it.
Want results from more Discord servers?
Add your server