Skip to content

Call to undefined method Whitecube\NovaFlexibleContent\Layouts\Layout::removeCallbackMethod() #540

Description

@sethcarter42

There seems to be a bug with the remove callback for a layout when passing a callable to the layout constructor for the $removeCallbackMethod argument

The bit where this occurs is:
https://github.com/whitecube/nova-flexible-content/blob/master/src/Layouts/Layout.php#L475

    public function fireRemoveCallback(Flexible $flexible)
    {
        if (is_callable($this->removeCallbackMethod)) {
            return $this->removeCallbackMethod($flexible, $this);
        }

        return $this->removeCallback($flexible, $this);
    }

This attempts to invoke a removeCallbackMethod method on the Layout class itself, which it doesnt have and throws the undefined method error.

This line should instead be changed to

    public function fireRemoveCallback(Flexible $flexible)
    {
        if (is_callable($this->removeCallbackMethod)) {
            return call_user_func($this->removeCallbackMethod, $flexible, $this);
        }

        return $this->removeCallback($flexible, $this);
    }

You can replicate this by passing any callback to the Layout constructors 6th argument and then attempting to remove a saved layout from an existing flexible field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions