© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
6 replies
Hedi

Repeater deletes the record instead of updating it

Hello, i have a repeater like this, the repeater is too long i'll just paste the essential lines
                    Forms\Components\Repeater::make('octaneStockProducts')
->dehydrated(true)
->relationship()
->live(onBlur: true)
->schema([
  TextInput('quantity_price'),
  TextInput('tax'),
  TextInput('actual_quantity_price')
])
->afterStateUpdated(function (Forms\Set $set, Forms\Get $get) use ($dollar_price) {
    CheckinResource::calculateActualPrices($get, $set, $dollar_price);
})
                    Forms\Components\Repeater::make('octaneStockProducts')
->dehydrated(true)
->relationship()
->live(onBlur: true)
->schema([
  TextInput('quantity_price'),
  TextInput('tax'),
  TextInput('actual_quantity_price')
])
->afterStateUpdated(function (Forms\Set $set, Forms\Get $get) use ($dollar_price) {
    CheckinResource::calculateActualPrices($get, $set, $dollar_price);
})

the problem occurs inside
CheckinResource::calculateActualPrices
CheckinResource::calculateActualPrices
, below is the code of this method
$stock_products = [];
foreach ($get('octaneStockProducts') as $index => $product) {
  //don't mind the math here, this is just for the sake of the sample code
     $product['actual_quantity_price']=$product['quantity_price']+$product['tax']

array_push($stock_products, $product);
}

$set('octaneStockProducts', $stock_products);
$stock_products = [];
foreach ($get('octaneStockProducts') as $index => $product) {
  //don't mind the math here, this is just for the sake of the sample code
     $product['actual_quantity_price']=$product['quantity_price']+$product['tax']

array_push($stock_products, $product);
}

$set('octaneStockProducts', $stock_products);

as you can see, i'm iterating through the repeater records, i calculate the actual_quantity_price, then add that changed record to a new list. then i assign that new list to the repeater.

this causes the repeater to delete all the records and creating new ones, i know this is kinda expected to happen. but i was wondering, is there like a primary key (using the id inside $product variable) that i can assign to each repeater, so instead of deleting and creating, it updates the record based on the $product's id. thanks for any suggestions!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

detach item from pivot with repeater instead of deleting the other record
FilamentFFilament / ❓┊help
13mo ago
Nested HasMany Repeater – deleteAction always receives parent record instead of child
FilamentFFilament / ❓┊help
4mo ago
$record in TableAction resolves to the first record in the list instead of current item.
FilamentFFilament / ❓┊help
3y ago
How to prepend next item instead of appending it in a Filament Repeater
FilamentFFilament / ❓┊help
2y ago