octobercms/october · error · ApplicationException

To display list as a tree, the model

Error message

To display list as a tree, the model {$modelClass} must implement methods found in October\Contracts\Database\TreeInterface, or set showTree to false

What it means

validateTree check in ListStructure: when the list is configured to show a tree structure, the bound model must implement October\Contracts\Database\TreeInterface so the list can query nested children (e.g. getChildCount). A model class lacking that contract cannot supply hierarchy data, so list initialization aborts with the offending model class name in the message.

Solutions

  1. Make the model implement October\Contracts\Database\TreeInterface (typically by using a nested tree behavior or extending a tree base model)
  2. Set showTree to false in the list configuration if a flat list is acceptable
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/backend/widgets/ListStructure.php:327 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/202d77e9a661e712. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/widgets/ListStructure.php:327

        }

        foreach ($records as $record) {
            if ($record->getChildCount()) {
                return true;
            }
        }

        return false;
    }

    /**
     * validateTree validates the model and settings if useStructure is used
     */
    public function validateTree()
    {
        if (!$this->model->isClassInstanceOf(\October\Contracts\Database\TreeInterface::class)) {
            $modelClass = get_class($this->model);
            throw new ApplicationException(
                "To display list as a tree, the model {$modelClass} must implement methods found in October\Contracts\Database\TreeInterface, or set showTree to false"
            );
        }
    }

    /**
     * useSortOrdering
     */
    public function useSortOrdering(): bool
    {
        return $this->includeSortOrders || $this->model->isClassInstanceOf(\October\Contracts\Database\SortableInterface::class);
    }

    /**
     * onReorder
     */
    public function onReorder()
    {

View on GitHub (pinned to b608633a7e)