FilamentF
Filament3y ago
Abi

When is afterStateUpdated triggered for a repeater?

I am trying to perform some calculations when a new row is added or deleted. I see that the afterStateUpdated is triggered when the row is added and details are added to the row, but can't seem to get the afterStateUpdated to work when a row is deleted.. Can you please advice if this is a bug or if I am missing something? This is for a standalone Form builder.

Here is the code I have
 Repeater::make('add_new_kids')
      ->schema([
         // Schema Fields go here
      ])->columnSpanFull()->columns(4)
      ->live()
      ->afterStateUpdated(function (Get $get) {
          $this->quantity = count($get('existing_kids') ?? []) + count($get('add_new_kids') ?? []);
          $this->subTotal = $this->quantity * $this->price;
      }),
Was this page helpful?