Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofill on HasMany relationship doesn't work when defined twice. #6397

Closed
YouneselBarnoussi opened this issue May 18, 2024 · 3 comments
Closed
Labels
bug Verified bug by the Nova team fix incoming A fix is in review

Comments

@YouneselBarnoussi
Copy link

  • Laravel Version: 11.7.0
  • Nova Version: 4.33.0
  • PHP Version: 8.2.18
  • Database Driver & Version: Mysql 8.0
  • Operating System and Version: Ubuntu 22.04.4 LTS
  • Browser type and version: Google Chrome Versie 122.0.6261.112
  • Reproduction Repository: https://github.com/YouneselBarnoussi/nova-hasmany-bug

Description:

The BelongsTo field doesn't always fill when there are two HasMany relationships to the same model. When you go to the detail page of the model and click on 'Create Relation' the BelongsTo 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() and members(), 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.

@crynobone
Copy link
Member

Can you send a video example of the step above?

@crynobone crynobone added the needs more info More information is required label May 20, 2024
@YouneselBarnoussi
Copy link
Author

2024-05-20.16-12-55.mp4

Let me know if there is anything else I can help with

@crynobone crynobone added bug Verified bug by the Nova team fix incoming A fix is in review and removed needs more info More information is required labels May 21, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team fix incoming A fix is in review
Projects
None yet
Development

No branches or pull requests

2 participants