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:Jump to solution
add
dehydrated()
in the repeater, after relationship()
You will able to get it in the $data
or $this->data
...10 Replies
Solution
add
dehydrated()
in the repeater, after relationship()
You will able to get it in the $data
or $this->data
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
Where?
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
is there other way to disable it
removing relationship?
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
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
Thanks,
But i think having an option to disable the save only will be great
i will try uploading PR to add this option
i just wanted to say thank you for this content! it helped me overcoming being stuck with some nested repeaters ❤️