did you solve it?
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.
Please or to participate in this conversation.