octobercms/october · error · SystemException

Form behavior used in :class does not have a model defined.

Error message

Form behavior used in :class does not have a model defined.

What it means

validateModel guard in the Form widget: it checks that a model instance was bound to the form before initialization continues. An empty model property means the controller/form configuration never supplied one (missing model in the config, or a create/update action that failed to find a record), so the form cannot be built.

Solutions

  1. Provide a model to the Form widget configuration, e.g. modelClass or an injected model instance
  2. In controller form behaviors, ensure the record can be resolved (correct find record ID) so a model is bound before init
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/backend/widgets/Form.php:379 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/70b4203738fc6e99. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/widgets/Form.php:379

    /**
     * initFormTabs
     */
    protected function initFormTabs()
    {
        $this->allTabs = (object) $this->allTabs;
        $this->allTabs->outside = new FormTabs(['section' => FormTabs::SECTION_OUTSIDE]);
        $this->allTabs->primary = new FormTabs(['section' => FormTabs::SECTION_PRIMARY]);
        $this->allTabs->secondary = new FormTabs(['section' => FormTabs::SECTION_SECONDARY]);
    }

    /**
     * validateModel validates the supplied form model.
     * @return mixed
     */
    protected function validateModel()
    {
        if (!$this->model) {
            throw new SystemException(Lang::get(
                'backend::lang.form.missing_model',
                ['class'=>get_class($this->controller)]
            ));
        }

        $this->data = isset($this->data)
            ? (object) $this->data
            : $this->model;

        // Non-existent models cannot use translatable features
        if (!$this->model->exists) {
            $this->useTranslatable = false;
        }

        return $this->model;
    }

    /**

View on GitHub (pinned to b608633a7e)