F
Filament4mo ago
aldec

mutateRecordDataUsing in Replicate Action not firing

I try to replicate a record with the prebuilt replicate action and want to change a field with a unique constraint before it is saved via the mutateRecordDataUsing() method as is described in the documentation. But the methods is never called, no mutating, no logging from this method. I just get an SQL error [2025-07-04 08:17:56] local.ERROR: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "roles_name_guard_name_unique" The complete getHeaderActions method looks like this:
public function getHeaderActions(): array
{
return [
ViewAction::make(),
DeleteAction::make(),
ReplicateAction::make()
->excludeAttributes(['permissions_count'])
->mutateRecordDataUsing(function (array $data): array {
Log::error('WHYYYYY you not working');
$data['name'] = $data['name'] . '(Kopie)';
return $data;
})
];
}
public function getHeaderActions(): array
{
return [
ViewAction::make(),
DeleteAction::make(),
ReplicateAction::make()
->excludeAttributes(['permissions_count'])
->mutateRecordDataUsing(function (array $data): array {
Log::error('WHYYYYY you not working');
$data['name'] = $data['name'] . '(Kopie)';
return $data;
})
];
}
Solution:
GitHub
mutateRecordDataUsing not mutating data when used with `Replicate...
Package filament/filament Package Version v3.2.40 Laravel Version v11.16.0 Livewire Version v3.5.4 PHP Version PHP 8.2 Problem description When using the mutateRecordDataUsing method with the Repli...
Jump to solution
2 Replies
Solution
Dan Harrin
Dan Harrin4mo ago
GitHub
mutateRecordDataUsing not mutating data when used with `Replicate...
Package filament/filament Package Version v3.2.40 Laravel Version v11.16.0 Livewire Version v3.5.4 PHP Version PHP 8.2 Problem description When using the mutateRecordDataUsing method with the Repli...
aldec
aldecOP4mo ago
Yes it does absolutely, thank you!

Did you find this page helpful?