You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Resource::fieldsForDetail to display certain fields different from what is displayed in index and update resource form.
when defining the relationship field HasMany inside the Resource::fieldsForDetail method the table will load normally, but the problem is when I click the Create XX button above this relationship table it will keeps loading and it will return a 404 error page at the logs.
The fix:
after hours of tweaking this I figured it could only work if the same relationship field is defined in the fields method, even if its hidden.
Detailed steps to reproduce the issue on a fresh Nova installation:
to reproduce this error you simply need to define a HasMany field in one resources' fieldsForDetail:
// following the example given in docs: https://nova.laravel.com/docs/4.0/resources/relationships.html#hasmany
class User extends Resource
{
public function fields(NovaRequest $request)
{
return [
Text::make('Name'),
];
}
public function fieldsForDetail(NovaRequest $request)
{
return [
HasMany::make('Posts'),
];
}
}
the example above wont work when you try to create a new post from inside user details page.
The text was updated successfully, but these errors were encountered:
@crynobone what you say actually is that I'm forced to use fields() at all cases and I cannot specify fields in different methods like fieldsForDetails and fieldsForIndex!
I would recommend using fields() and only uses dynamic fields for further customisation. Internally for relations checking we would prefer to filters all dynamic fields to avoid false positive and avoid performance penalty when we need to check if the field actually exists in a resource.
Description:
I'm using
Resource::fieldsForDetail
to display certain fields different from what is displayed in index and update resource form.when defining the relationship field
HasMany
inside theResource::fieldsForDetail
method the table will load normally, but the problem is when I click theCreate XX
button above this relationship table it will keeps loading and it will return a 404 error page at the logs.The fix:
after hours of tweaking this I figured it could only work if the same relationship field is defined in the
fields
method, even if its hidden.Detailed steps to reproduce the issue on a fresh Nova installation:
to reproduce this error you simply need to define a
HasMany
field in one resources'fieldsForDetail
:the example above wont work when you try to create a new post from inside user details page.
The text was updated successfully, but these errors were encountered: