Repeater ->relationship() inside multiple Group ->relationship() in a form issue
Hi! I’m having an issue with relationships in my form.
I have a resource with a form based on my Inscription model.
In this model, I have one student belongTo(Student::class) relationship.
In my Student model, I have two relationships:
AAAs → hasMany(AAA::class)
BBBs → hasMany(BBB::class)
In my form, I have fields like this:
and later:
The BBBs repeater displays its data correctly, but the AAAs repeater shows nothing.
However, when I move the AAAs repeater into the same Group as the BBBs one, it works:
I don’t understand why I can’t have them in separate groups.
if i move AAAs repeater Group after BBBs repeater Group, AAAs is working but BBBs dont anymore ...
If anyone has an idea...
5 Replies
You can try giving both Groups a unique key
Group::make()->key('student_aaa'), but it might be the saving logic that only allows one Group with the same relation.nop ->key doesnt work. And it dont seem to be on the saving logic cause when i add something in my AAAs, repeater, its well saved in the database, but not displayed on the form, only the last Group::make->relationship('student') display the repeater records well ...
when i add a mutateRelationshipDataBeforeFillUsing on my buggy repeater, i can see my datas, but the repeater doesnt fill ...
Sorry, but what element is this? A Group element having a relationship method?
I found a way to work around the issue by adding a ->mutateRelationshipDataBeforeFillUsing() on the last Group::make()->relationship('student') in my form to fill the previous Group::make()->relationship('student') blocks.
But it feels a bit weird...
Am I trying to do something too complicated? Was it not meant to be used that way?
Are we only supposed to have only one Group::make()->relationship('') for the same relationship?
Another thing I hadn’t mentioned: each group is in a different tab.