Persisting repeater changes to DB (TableRepeter)

I have a somewhat complex repeater table where I'm populating the table with custom calculations essentially, so when I use the relationship() method, it doesn't work. What I need to do is in each repeater field's afterStateUpdated method, I want to get the current row and save the changes to the database. It seems like this should be pretty straight-forward, but I think the repeater is relying on a pretty simple relationship and not designed for my use case? Either that or I'm just too dumb to figure it out. I've tried various things trying to get the $component->getContainer() and use that to get the ID of the row? I really just need to get the ID of the row, which is in my data, so if I could get the row data I'd be happy. I tried passing in array $data , array $arguments, Repeater $component, nothing seems to give me anything useful. What am I missing, because it seems like this should be easy.
->afterStateUpdated(function (TextInput $component, ?string $state, ?string $old, Get $get, Set $set) {
???
}
->afterStateUpdated(function (TextInput $component, ?string $state, ?string $old, Get $get, Set $set) {
???
}
1 Reply
Jon Mason
Jon MasonOP3w ago
turns out I am dumb. I didn't realize that $get() would work on data that's not an actual field. The ID of my row isn't an input field...I just tried it on a whim and it returns my id, so I learned something new today.

Did you find this page helpful?