Saving repeater without using the saveRelationShipUsing

Hi, I have a repeater with nested relations the repeater does not save it right because every model consist of more than table so i need to save it using custom code in SaveRelationUsing it is working now but this pattern repeater in multiple resources so i need to extract this logic to afterSave hook but the issue is the repeater values is not present in $data array Is there any way to access the updated values of repeater fields in after or before save hooks?
Solution:
add dehydrated() in the repeater, after relationship() You will able to get it in the $data or $this->data...
Jump to solution
10 Replies
Solution
LeandroFerreira
LeandroFerreira3mo ago
add dehydrated() in the repeater, after relationship() You will able to get it in the $data or $this->data
A7med_khalid
A7med_khalid3mo ago
thanks, i will try it Great now the relation is present in $data array but it is not updated with user input it is just showing the last values from database
LeandroFerreira
LeandroFerreira3mo ago
Where?
A7med_khalid
A7med_khalid3mo ago
mutateFormDataBeforeSave also afterSave tried dd both $data and this->data yes i am trying to save it manually but in edit not create It is not updating the value because i am trying to return empty array to disable the repeater save
->saveRelationshipsUsing(function () {
return [];
}),
->saveRelationshipsUsing(function () {
return [];
}),
is there other way to disable it
LeandroFerreira
LeandroFerreira3mo ago
removing relationship?
A7med_khalid
A7med_khalid3mo ago
it works but i will not populate the repeater with value i need to do it manually Maybe by returning the right object here i will get values updated
LeandroFerreira
LeandroFerreira3mo ago
yes, overriding the default behavior you should do all. Check the hooks to achieve what you need https://filamentphp.com/docs/3.x/panels/resources/editing-records
A7med_khalid
A7med_khalid3mo ago
Thanks, But i think having an option to disable the save only will be great i will try uploading PR to add this option
ana
ana2mo ago
i just wanted to say thank you for this content! it helped me overcoming being stuck with some nested repeaters ❤️