F
Filament2mo ago
Akimbo

EMERGENCY - before, using, and mutateRecordDataUsing doesn't work for EditAction

This is not working for a client that needs this done tomorrow. These methods work on the DeleteAction but not edit.
Tables\Actions\EditAction::make()
->mutateRecordDataUsing(function (array $data): array {
$data['title'] = 'asd';

return $data;
})
->hidden(!$can_edit_events),
Tables\Actions\EditAction::make()
->mutateRecordDataUsing(function (array $data): array {
$data['title'] = 'asd';

return $data;
})
->hidden(!$can_edit_events),
This does not work.
->mutateFormDataUsing(function (array $data): array {
$data['title'] = 'asd';

return $data;
})
->mutateFormDataUsing(function (array $data): array {
$data['title'] = 'asd';

return $data;
})
Does not work
4 Replies
Dennis Koch
Dennis Koch2mo ago
What are you trying to do? You are telling us, something isn't working, but not what you want to do.
These methods work on the DeleteAction but not edit.
This sentence doesn't make sense. Why would you want to modify form data on a DeleteAction which doesn't have a form.
toeknee
toeknee2mo ago
Think he is saying the actions work on delete but not edit I recon it is working, but I suspect the form doesn't have or isn't allowing updating the title. Yep just tested it myself:
Tables\Actions\EditAction::make()->mutateFormDataUsing(function (array $data): array {
$data['first_name'] = 'first_namesss';

return $data;
}),
Tables\Actions\EditAction::make()->mutateFormDataUsing(function (array $data): array {
$data['first_name'] = 'first_namesss';

return $data;
}),
changes my users first_name to first_namesss when saving. So this action works perfectly well. Also tested:
->mutateRecordDataUsing(function (array $data): array {
$data['first_name'] = 'ddddddf';

return $data;
}),
->mutateRecordDataUsing(function (array $data): array {
$data['first_name'] = 'ddddddf';

return $data;
}),
Also changes my users name to dddddddf on load when editing the record, again working as expected.
Dennis Koch
Dennis Koch2mo ago
Is your title in $fillable or your fields unguarded?
LeandroFerreira
LeandroFerreira2mo ago
Just to say that if you are using a EditPage, you should use this

Did you find this page helpful?