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
jaocero8mo 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
cenglyyOP8mo ago
but dont have action
cenglyy
cenglyyOP8mo ago
No description
cenglyy
cenglyyOP8mo ago
@jaocero using Resource
jaocero
jaocero8mo 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
cenksen8mo ago
@cenglyy
cenglyy
cenglyyOP8mo ago
buyrun:)
cenksen
cenksen8mo ago
Sana yazmış beni etiketlemis 🙂
cenglyy
cenglyyOP8mo ago
😄
cenksen
cenksen8mo ago
İyi çalışmalar dostum 🙂
cenglyy
cenglyyOP8mo 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
Want results from more Discord servers?
Add your server