Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlbertLens's avatar

Repeater in Filament. Need to recalculate total value in parent when deleting an item

Hello. I am using Filamentphp and its repeater for delivery notes and its multiple items. Everything is working fine but if user deletes an item in repeater I do not know how to control that deletion to make a function for recalculation of total amount of the delivery note.

Any ideas of how to control that? I have checked repeater itself has no ->afterStateUpdated() function such as the following code (which is working perfectly in several Forms\Components\TextInput form components):

->afterStateUpdated(function (callable $get, callable $set, $state) {
                        $itemsColumn = array_column($get('../../items'), 'amount');
                        $sumaItemsColumn = array_sum($itemsColumn);
                        $set('../../subtotal', number_format($sumaItemsColumn,2));
                    })

or a afterElementDeleted() or something like that.

By the way, I need the user to see the total accumulated amount of the delivery note while creating it. Otherwise, this could be done afterwards with an observer, for example.

Thanks in advance.

0 likes
2 replies
akilaanu's avatar

I may have found a solution for this. I also faced this kind of situation and I used this

Forms\Components\Repeater::make('attribute')
->schema([
            //your repeater schema here
 ])
->->deleteAction(function (Forms\Get $get, Forms\Set $set){
           //you can tell here what do you want to do with delete action
});

Please or to participate in this conversation.