F
Filamentβ€’2y ago
Zeldroxe

Change how repeater saves relationships

Hi, I have a form allowing me to create and modify activity bookings. For each booking, there are activities with several rates available. I would like that for each activity (repeater) in a booking, the administrator can choose the number of each rate. To do this, I have created a ViewField with a custom view that generates a label and a numeric field for each rate of the selected activity. How can I now get this data to create / modify my "bookingsActivityRates" relationship? I have tried with the "mutateRelationshipDataBeforeSaveUsing()" function but when creating, I cannot create the relationships as the function is called before creating the booking and the booked activity.
5 Replies
Zeldroxe
ZeldroxeOPβ€’2y ago
Maybe more understandable with a screenshot
Zeldroxe
ZeldroxeOPβ€’2y ago
Zeldroxe
ZeldroxeOPβ€’2y ago
Maybe something like the handleRecordUpdate() method but for my repeater with relationship ? Up ? πŸ˜•
Dan Harrin
Dan Harrinβ€’2y ago
open Repeater.php and search for saveRelationshipsUsing() you can see the default implementation of that method you can chain ->saveRelationshipsUsing() onto your own repeater and modify the behaviour in whatever way you need to save to the other table
Zeldroxe
ZeldroxeOPβ€’2y ago
Thank you very much! That's exactly what I was trying to do. I have succeeded.
Want results from more Discord servers?
Add your server