404 in modal after deleting a record on a custom page
I've got a custom page where I list records and for every record I load a custom livewire component to manage the recoord based content in a filament section. Under each section I have a DeleteAction to delete the record. When I click the button the confirmation modal opens and if I click on confirmate the record is deleted. But the modal don't close and shows instead a 404 Error. If I click away the 404 error disappears and the confirmation modal is shown again. Now, if I click on cancel, again a 404 error is shown. If I click again away from the modal, the modal is at least closed. But the page doesn't refresh. I've no idea, what I'm doing wrong.
The createActtion on the same page is working as expected.
Solution:Jump to solution
Thanks for your proposal. Unfortunately the 404 error doesn't disappear. At least I found the error:
For the record of the delete action i used
...
2 Replies
The issue you're experiencing — where clicking "Confirm" on the DeleteAction results in a 404 error and the modal not closing properly — is likely due to how the route binding, Livewire, and Filament page context are handled.
Try using the following code:
public function deleteTableAction(): DeleteAction
{
return DeleteAction::make('deleteTable')
->record(fn(ProjectDataImportTable $record) => $record)
->action(function (ProjectDataImportTable $record) {
$record->delete();
})
->successRedirectUrl(url()->current());
}
If you're using a custom Livewire component inside the Page, you must pass the record directly to avoid findOrFail() errors. If you use IDs, ensure they’re properly passed and exist in the model
Solution
Thanks for your proposal. Unfortunately the 404 error doesn't disappear. At least I found the error:
For the record of the delete action i used
The problem was the return type ProjectDataImportTable. After removing the return type everything worked as aspected: