BelongsTo fails validation when creating if already exists on another record
grantholle opened this issue · 3 comments
grantholle commented
- 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:
- Create a
BelongsTo
relationship and field on a model. - Create a new resource in Nova with a value for the
BelongsTo
field. - Attempt to create another resource with the same
BelongsTo
field value. - See validation message.
- Save as an empty/null value.
- Update the resource with the original
BelongsTo
value. - Updates successfully.
crynobone commented
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)
grantholle commented
I tried but can't reproduce it. That's a great feeling.
grantholle commented
I found it had to do with my reciprocal relationship. Just needed to be refactored.