Skip to content

fieldsForDetail is evaluted on Index page by Filters (it should not be) #5723

@cserepesmark

Description

@cserepesmark
  • Laravel Version: 9.52.10
  • Nova Version: 4.26.4
  • PHP Version: 8.1.13

Description:

I have a Product Nova Resource in which I would like to have very separate fields for Index and Details. The reason for this is that I have a very complex custom field which I do not want to show on Index. Nova's Filter function does not respect it.

When you open the Index page of the resource (code) below, you get an Exception on /nova-api/products/filters. I think fieldsForDetail should not be run / evaluated on Index page.

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

<?php

namespace App\Nova;

use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class Product extends Resource
{
    public static $model = \App\Models\Assets\Product::class;

    public function fields(NovaRequest $request)
    {
        return [];
    }

    public function fieldsForIndex(NovaRequest $request)
    {
        return [
            Text::make('Label'),
        ];
    }

    public function fieldsForDetail(NovaRequest $request)
    {
        throw new \Exception('it was called');
        return [];
    }

    public function fieldsForCreate(NovaRequest $request)
    {
        return $this->fieldsForDetail($request);
    }

    public function fieldsForUpdate(NovaRequest $request)
    {
        return $this->fieldsForDetail($request);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions