nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

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

Open sethcarter42 opened this issue 6 months ago • 0 comments

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.

sethcarter42 avatar May 11 '25 16:05 sethcarter42