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

Global search is broken, when using NestedForm #124

Open
bernhardh opened this issue Jan 13, 2021 · 4 comments
Open

Global search is broken, when using NestedForm #124

bernhardh opened this issue Jan 13, 2021 · 4 comments

Comments

@bernhardh
Copy link

I have a resource User with a nested Form Posts, just like the example in the documentation:

NestedForm::make('Posts', 'posts', \App\Nova\Post::class)

Now, the global search is broken, since the API (/nova-api/search?search=test) returns a 404 error instead of the json result. Commenting out the nested form and everything works as expected.

The relation itself work. When I add the HasMany field (and leave the NestedForm commented out), everything still works as expected:

HasMany::make("Posts", "posts",  \App\Nova\Post::class),
@GewoonRoy
Copy link

i have the same issue. Did you manage to fix it or have a workaround?

@bernhardh
Copy link
Author

Nope. I haven't fixed this issue yet.

@skywalker666
Copy link

The problem is in src/NestedForm.php:200 which got introduced in commit 0905cca . I'm not sure what it actually does, but latest Nova seems to work without it.

tomheno pushed a commit to tomheno/laravel-nova-nested-form that referenced this issue Feb 7, 2022
@tomheno
Copy link

tomheno commented Feb 7, 2022

By adding a condition before src/NestedForm.php:200 line, the search is working again :

// Added this condition, so the error doesn't occur when the request is a GlobalSearchRequest
if(get_class(app(NovaRequest::class)) !== "Laravel\Nova\Http\Requests\GlobalSearchRequest") 
     $this->resolve(app(NovaRequest::class)->model());

Did a PR

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

4 participants