modal with mutateData

Hello, in filament I delete the getPages create part and open the forms modally, but how can I use mutateFormDataBeforeCreate here?
11 Replies
jaocero
jaocero3mo ago
CreateAction::make()
->mutateFormDataUsing(function (array $data): array {
$data['user_id'] = auth()->id();

return $data;
})
CreateAction::make()
->mutateFormDataUsing(function (array $data): array {
$data['user_id'] = auth()->id();

return $data;
})
cenglyy
cenglyy3mo ago
but dont have action
cenglyy
cenglyy3mo ago
No description
cenglyy
cenglyy3mo ago
@jaocero using Resource
jaocero
jaocero3mo ago
@cenksen I didn't tried it yet but you can go to your list collection you can see the Actions\CreateAction::make() there or go to your create collection resource then you can modify the saving of data using:
protected function handleRecordCreation(array $data): Model
{
// modify here
return static::getModel()::create($data);
}
protected function handleRecordCreation(array $data): Model
{
// modify here
return static::getModel()::create($data);
}
again I din't try it yet
cenksen
cenksen3mo ago
@cenglyy
cenglyy
cenglyy3mo ago
buyrun:)
cenksen
cenksen3mo ago
Sana yazmış beni etiketlemis 🙂
cenglyy
cenglyy3mo ago
😄
cenksen
cenksen3mo ago
İyi çalışmalar dostum 🙂
cenglyy
cenglyy3mo ago
teşekkürler size de:) Fixed, thank you 🙂 protected function getHeaderActions(): array { return [ Actions\CreateAction::make()->mutateFormDataUsing(function (array $data): array { $data['operator_id'] = auth()->id(); return $data; }) ]; } Yes, this worked but when saving the data, this time it does not save it to the database @jaocero