F
Filament10mo ago
prouse_

Access repeater data afterSave

I have a relationship repeater and inside it there is also a checkbox that doesn't really exist in the model. In the Edit Record Page I want to do some logic with all the items that had the checkbox checked after saving. $this->form->getState() won't return any of the repeater data. Probably because it's a relationship repeater which disables dehydration from what I can tell. And $this->data for some reason always returns false on the checkbox column even though it's checked. I'm assuming because it somehow, somewhere fetches/rehydrates the data from the relationship and since the column does not exist it gets null and else false. So my question is how can access the original data or somehow get all the items that had this checkbox checked?
7 Replies
David | Fortune Validator
Did you find an answer to this one ?
Adnan Yalahow
Adnan Yalahow5mo ago
where exactly do you need to access it from inside repeater or in anther component share you code
toeknee
toeknee5mo ago
I think you'll struggle, you might be able to do it on the data on the afterCreate and then map the data accordingly.
David | Fortune Validator
I went for doing it after the Save in the end and mapping the data I needed. It needed to access it on another component. Eg a total price is the total of all repeater values.
toeknee
toeknee5mo ago
Why not just sum the records?
tesse05
tesse055mo ago
maybe using this instead of afterSave() ?
-relationship('...')
->saveRelationshipsUsing(function ($state, $livewire) {
...
}
})
-relationship('...')
->saveRelationshipsUsing(function ($state, $livewire) {
...
}
})
David | Fortune Validator
I’ll give this a go later thank you. I did also try having the repeater values sum after state updated but it was creating some lag and missed key strokes. Which is why I was hoping to perform the sum just before saving. ^
Want results from more Discord servers?
Add your server