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

BUG: Compatibility with fieldsForIndex, fieldsForDetail functions on Nova 3.X #169

Closed
albertgpdev opened this issue May 4, 2021 · 6 comments

Comments

@albertgpdev
Copy link

Hi I am experiencing some issues with the Nova 3.X fieldsForIndex, fieldsForDetail functions and looking in the code, I have found that the problem is due to this function where I think these two lines are missing to be compatible with those functions

$method = $this->fieldsMethod($request);
$fields = $this->filter($this->filter($this->{$method}($request)));

The function should look like this:


public function availableFields(NovaRequest $request)
    {
        $method = $this->fieldsMethod($request);

        // needs to be filtered once to resolve Panels
        $fields = $this->filter($this->filter($this->{$method}($request)));
        $availableFields = [];

        foreach ($fields as $field) {
            if ($field instanceof NovaDependencyContainer) {
                $availableFields[] = $this->filterFieldForRequest($field, $request);
                if ($field->areDependenciesSatisfied($request) || $this->extractableRequest($request, $this->model())) {
                    if ($this->doesRouteRequireChildFields()) {
                        $this->extractChildFields($field->meta['fields']);
                    }
                }
            } else {
                $availableFields[] = $this->filterFieldForRequest($field, $request);
            }
        }

        if ($this->childFieldsArr) {
            $availableFields = array_merge($availableFields, $this->childFieldsArr);
        }

        $availableFields = new FieldCollection(array_values($this->filter($availableFields)));

        return $availableFields;
    }

Best,

@jp-gauthier
Copy link

Solved by this pull request : #170

@ragingdave
Copy link
Collaborator

merged #170

@BinaryKitten
Copy link

Hi Team,

Is there any chance that this can be pushed to a release? - i see the bug fix has been merged to master, but no subsequent release or tag made so packagist hasn't updated.

Would be appreciative if we could?
Thanks

@ragingdave
Copy link
Collaborator

Tagged v1.3.3!

@stefblokdijk
Copy link

stefblokdijk commented Jul 11, 2021

I noticed that PR #170 resulted in the following error

Call to undefined method App\Nova\Campaign::fieldsMethod()

I recently upgrade from 1.3.2 to 1.3.3. I'm using Nova version 2.12.2 and Laravel 5.8.38 on this project.

@BinaryKitten
Copy link

I noticed that PR #170 resulted in the following error

Call to undefined method App\Nova\Campaign::fieldsMethod()

I recently upgrade from 1.3.2 to 1.3.3. I'm using Nova version 2.12.2 and Laravel 5.8.38 on this project.

yeah this was a deliberate patch for Nova 3 -
not sure on what @ragingdave thinks, but you can limit your inclusion of this in your composer.json to 1.3.2 it will prevent the error.

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

5 participants