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 field throws "Trying to get property of non-object" error. #27

Closed
karlozadro opened this issue Dec 14, 2018 · 3 comments
Closed

Comments

@karlozadro
Copy link

karlozadro commented Dec 14, 2018

I've been working on implementing this in a new project I'm working on and so far it's been great! However, I'm running in an issue when trying to add a nested form which uses a BelongsTo field.

The specific error I'm getting is happening happening within the index function of laravel/nova/src/Http/Controllers/AssociatableController.php, specifically at line 23. As far as I can tell, the $field variable is returning null because the Nova isn't able to find the resource.

I've been digging around a bit and I believe the issue is being cause by an incorrectly formatted API call to the /nova-api/RESOURCE/associatable endpoint. When I load the resource through a nested form, it tries to call the API at /nova-api/admission-referral-informations/associatable/nested:referralInformation[county] (which throws a 500 error), but when I load the resource as a standard Nova relationship field, it calls the API at /nova-api/admission-referral-informations/associatable/county (which works).

So basically the nested form uses nested:referralInformation[county] in the URL, when it should actually just be using county. I'll keep digging around to see if I can fix it on my own, but please let me know if you have a better idea of what's going on/if you need more info.

Thanks!

@yassilah
Copy link
Owner

Hi,
Just update the package and remove the Trait (which was responsible for redirecting the API calls) as it’s no longer needed :)

@karlozadro
Copy link
Author

😂 I thought I was on 2.0.0, but I guess not! Thanks a ton!

@yassilah
Copy link
Owner

You’re very welcome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants