octobercms/october · error · ApplicationException

The model must implement the NestedTree or Sortable traits.

Error message

The model must implement the NestedTree or Sortable traits.

What it means

validateModel inspects class_uses($model) and throws an ApplicationException when the model implements neither the Sortable nor the NestedTree trait, since reordering depends on one of those behaviors to persist order.

Solutions

  1. Add the October\Rain\Database\Traits\Sortable (or NestedTree) trait to the model and its $implement array
  2. Verify the model class used by ReorderController is the one carrying the trait
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/backend/behaviors/ReorderController.php:218 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/172488c86bc53caa. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/behaviors/ReorderController.php:218

    }

    /**
     * validateModel validates the supplied form model.
     */
    protected function validateModel()
    {
        $model = $this->controller->reorderGetModel();
        $modelTraits = class_uses($model);

        if (isset($modelTraits[\October\Rain\Database\Traits\Sortable::class])) {
            $this->sortMode = 'simple';
        }
        elseif (isset($modelTraits[\October\Rain\Database\Traits\NestedTree::class])) {
            $this->sortMode = 'nested';
            $this->showTree = true;
        }
        else {
            throw new ApplicationException('The model must implement the NestedTree or Sortable traits.');
        }

        return $model;
    }

    /**
     * Returns all the records from the supplied model.
     * @return Collection
     */
    protected function getRecords()
    {
        $records = null;
        $model = $this->controller->reorderGetModel();
        $query = $model->newQuery();

        $this->controller->reorderExtendQuery($query);

        if ($this->sortMode == 'simple') {

View on GitHub (pinned to b608633a7e)