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

BelongsTo fails validation when creating if already exists on another record #6409

Closed
grantholle opened this issue May 28, 2024 · 3 comments
Closed
Labels
needs more info More information is required

Comments

@grantholle
Copy link

  • Laravel Version: 11.8.0
  • Nova Version: 4.34.2
  • PHP Version: 8.3.3
  • Database Driver & Version: Postgres 14
  • Operating System and Version: macOS 14.5
  • Browser type and version: Brave v1.66.113

Description:

When attempting to create a resource with a BelongsTo relation value that already is associated with another resource, it will fail validation with the message "This {field resource name} may not be associated with this resource."

I can, however, save the BelongsTo as null and update it with the same resource value that was used when trying to create it.

Detailed steps to reproduce the issue on a fresh Nova installation:

  1. Create a BelongsTo relationship and field on a model.
  2. Create a new resource in Nova with a value for the BelongsTo field.
  3. Attempt to create another resource with the same BelongsTo field value.
  4. See validation message.
  5. Save as an empty/null value.
  6. Update the resource with the original BelongsTo value.
  7. Updates successfully.
@crynobone
Copy link
Member

Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

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

I tried but can't reproduce it. That's a great feeling.

@grantholle
Copy link
Author

I found it had to do with my reciprocal relationship. Just needed to be refactored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More information is required
Projects
None yet
Development

No branches or pull requests

2 participants