Closed YouneselBarnoussi closed 6 months ago
Can you send a video example of the step above?
https://github.com/laravel/nova-issues/assets/16510310/8a2e502e-0221-429a-b473-aa06cd4174f1
Let me know if there is anything else I can help with
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Description:
The
BelongsTo
field doesn't always fill when there are twoHasMany
relationships to the same model. When you go to the detail page of the model and click on 'Create Relation' theBelongsTo
field does get filled for the related model in the first relationship but not in the second. For more clarification check below.Detailed steps to reproduce the issue on a fresh Nova installation:
A complete guide is found in the readme of the reproduction repository but I will copy it here aswell:
Lets say we have a user that can belong to many teams. The TeamUser pivot/model has a role which is used to filter between admins and members.
The Team model has two HasMany relationships to TeamUser
admins()
andmembers()
, the difference is the filteration on the role column.Now navigate to the teams resource and go to the detail page of the team.
Click on Create Team User for admins. You can see that the Team relationship is automatically filled with the correct team.
Now go back.
Click on Create Team User for members. You can see that the Team relationship is empty for some reason.
Now go to the file Team Nova resource file and move the members relationship above the admin relationship, and repeat the steps above.
Then you will see the same result but flipped, so it seems like the autofill only works for the first relationship.