Displaying CheckboxList across multiple Fieldsets using relationship
I have Fleets, Vessels and RemoteScripts.
A RemoteScript belongs to many Vessels via a pivot table, a Vessel belongs to a Fleet.
When I do
CheckboxList::make('vessels')->('vessels', 'name')
it works and displays all the Vessels in the list, checking and unchecking boxes is reflected in the pivot table. But I would like to display each CheckboxList in a Fieldset for each Fleet.
Between Google and GPT I have got this
This lists each CheckboxList in a Fieldset for each Fleet but the pivot table is not updating nor are the records in the pivot table reflected in the checkboxes.
I have seen ->saveRelationshipsUsing()
, is this something that will help resolve this issue?
Cheers, TeeSolution:Jump to solution
@Dennis Koch I managed to fudge something together... I won't post the code cos its a mess but if someone did have the same problem I am happy to share it π I ended up using afterStateUpdated, default and afterStateHydrated to get it going how I wanted... probs a better way but for now I just needed the functionality π
2 Replies
Currently it works because you use
->relationship()
right? If you want to split your CheckboxLists up, you need to save the data yourself. Best to just overwrite the save()
method of that page and combine them thereSolution
@Dennis Koch I managed to fudge something together... I won't post the code cos its a mess but if someone did have the same problem I am happy to share it π I ended up using afterStateUpdated, default and afterStateHydrated to get it going how I wanted... probs a better way but for now I just needed the functionality π