F
Filament2mo ago
Harvey

Relation caching after calling action

When I call my TextEntry action to upload a document, the document count does not update. It's like the documents relation is being cached somehow. It was not like this in v3 The TextEntry in question:
TextEntry::make('test')
->state(function (Claim $claim) {
return $claim
->documents
->filter(fn(Document $doc) => $doc->type == DocumentTypes::DETAILS)
->count();
})
->hintAction(
Action::make('upload')
->schema([
FileUpload::make('file'),
])
->action(function (Claim $claim, array $data) {
$claim->documents()->create([
'type' => DocumentTypes::DETAILS,
'path' => $data['file'],
]);
}),
),
TextEntry::make('test')
->state(function (Claim $claim) {
return $claim
->documents
->filter(fn(Document $doc) => $doc->type == DocumentTypes::DETAILS)
->count();
})
->hintAction(
Action::make('upload')
->schema([
FileUpload::make('file'),
])
->action(function (Claim $claim, array $data) {
$claim->documents()->create([
'type' => DocumentTypes::DETAILS,
'path' => $data['file'],
]);
}),
),
2 Replies
Harvey
HarveyOP2mo ago
GitHub
suffixAction() callback does not receive updated model collection w...
Package filament/filament Package Version v4.0.4 Laravel Version v12.26.3 Livewire Version v3.6.4 PHP Version PHP 8.3.0 Problem description When a suffix action is provided to an infolist entry as ...
Harvey
HarveyOP2mo ago
The cause seems to be the callback method to suffixAction, it is not passed update relation values like the others. When I don't rely on a callback to suffixAction it updates as expected.

Did you find this page helpful?