© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
gladjanus43

Delete repeater items from UI and database at the same time

Inside of the edit action of a relationmanager I have a repeater form. Everything is working correct but now I need to delete the items. From a UX standpoint I dont like it that a user needs to press Save before the item is actually deleted. I have tried some things where the item is deleted from the database but then the UI is not updated.

Then the other option is to use the standard delete but then you need to press save which in my opinion is not needed. Does anybody have a solution where both requirements are met?

I have tried this in my code:

->deleteAction(function ($action) {
    // $action->requiresConfirmation();
    $action->action(function ($state, array $arguments) {
        $key = $arguments['item'];
        $record = $state[$key];
        $attachment = Attachment::findOrFail($record['id'])->delete();
    });
})
->deleteAction(function ($action) {
    // $action->requiresConfirmation();
    $action->action(function ($state, array $arguments) {
        $key = $arguments['item'];
        $record = $state[$key];
        $attachment = Attachment::findOrFail($record['id'])->delete();
    });
})
Screenshot_2023-12-18_at_12.38.29.png
Screenshot_2023-12-18_at_12.38.38.png
Solution
this works, deletes the item from the ui and with a custom delete statement

Repeater::make('Attachments')
                ->relationship('attachments')
                ->columns(2)
                ->hiddenLabel()
                ->deleteAction(
                    function ($action) {
                        $action->requiresConfirmation();
                        $action->before(function (array $arguments, Repeater $component) {
                            $itemData = $component->getItemState($arguments['item']);
                            AttachmentService::deleteAttachment(Attachment::find($itemData['id']));
                        });
                    }
                )
                ->schema([...])
Repeater::make('Attachments')
                ->relationship('attachments')
                ->columns(2)
                ->hiddenLabel()
                ->deleteAction(
                    function ($action) {
                        $action->requiresConfirmation();
                        $action->before(function (array $arguments, Repeater $component) {
                            $itemData = $component->getItemState($arguments['item']);
                            AttachmentService::deleteAttachment(Attachment::find($itemData['id']));
                        });
                    }
                )
                ->schema([...])
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

custom page repeater does not delete from database
FilamentFFilament / ❓┊help
3y ago
Thin side bar and ☰ at the same time
FilamentFFilament / ❓┊help
3y ago
Repeater sum Items and quantities
FilamentFFilament / ❓┊help
3y ago
Masking and using palceholder at same time
FilamentFFilament / ❓┊help
3y ago