getgrav/grav · error · RuntimeException

Switching Flex Page object during onAdminSave event is not s

Error message

Switching Flex Page object during onAdminSave event is not supported! Please update plugin.

What it means

Error "Switching Flex Page object during onAdminSave event is not supported! Please update plugin." thrown in getgrav/grav.

Source

Thrown at system/src/Grav/Common/Flex/Types/Pages/PageObject.php:310

        }
    }

    /**
     * @param array|bool $reorder
     * @return static
     */
    public function save($reorder = true)
    {
        $variables = $this->onBeforeSave(func_get_args());

        // Backwards compatibility with older plugins.
        $fireEvents = $reorder && $this->isAdminSite() && $this->getFlexDirectory()->getConfig('object.compat.events', true);
        $grav = $this->getContainer();
        if ($fireEvents) {
            $self = $this;
            $grav->fireEvent('onAdminSave', new Event(['type' => 'flex', 'directory' => $this->getFlexDirectory(), 'object' => &$self]));
            if ($self !== $this) {
                throw new RuntimeException('Switching Flex Page object during onAdminSave event is not supported! Please update plugin.');
            }
        }

        /** @var static $instance */
        $instance = parent::save();
        $variables = $this->onSave($variables);

        $this->onAfterSave($variables);

        // Backwards compatibility with older plugins.
        if ($fireEvents) {
            $grav->fireEvent('onAdminAfterSave', new Event(['type' => 'flex', 'directory' => $this->getFlexDirectory(), 'object' => $this]));
        }

        // Reset original after save events have all been called.
        $this->_originalObject = null;

        return $instance;

View on GitHub (pinned to 6040efed04)

When it happens

Trigger: Thrown at system/src/Grav/Common/Flex/Types/Pages/PageObject.php:310 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17). Data as JSON: /api/errors/8a54a74f16101c0b. Report an issue: GitHub.