octobercms/october · error · SystemException

The attribute ':field' does not resolve to a valid model…

Error message

The attribute ':field' does not resolve to a valid model. Try specifying the options method for model class :model explicitly.

What it means

Thrown by FormField::getOptionsFromModelAsDefault when the field name cannot be resolved to a related model attribute while trying to auto-derive options. This is the fallback path when no explicit options are configured: resolving the field's model relation/attribute threw, so the error suggests declaring the options method explicitly.

Solutions

  1. Define an explicit options method on the model (e.g. getFieldNameOptions) or set options in the field config
  2. Fix the field name so it resolves to an existing attribute or relation on the model
  3. For relation fields, ensure the relation is properly defined on the model class
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at modules/backend/classes/FormField.php:567 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/e09ac0a7020ee400. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/classes/FormField.php:567

                ]));
            }

            $fieldOptions = $model->$methodName($this->value, $this->fieldName, $data);
        }

        return $fieldOptions;
    }

    /**
     * getOptionsFromModelAsDefault refers to the model method or any of its behaviors
     */
    protected function getOptionsFromModelAsDefault($model, $data)
    {
        try {
            [$model, $attribute] = $this->resolveModelAttributeInternal($model, $this->fieldName, ['objectOnly' => true]);
        }
        catch (Exception $ex) {
            throw new SystemException(Lang::get('backend::lang.field.options_method_invalid_model', [
                'model' => get_class($model),
                'field' => $this->fieldName
            ]));
        }

        $methodName = 'get'.studly_case($attribute).'Options';
        if (
            !$this->objectMethodExists($model, $methodName) &&
            !$this->objectMethodExists($model, 'getDropdownOptions')
        ) {
            throw new SystemException(Lang::get('backend::lang.field.options_method_not_exists', [
                'model' => get_class($model),
                'method' => $methodName,
                'field' => $this->fieldName
            ]));
        }

        if ($this->objectMethodExists($model, $methodName)) {

View on GitHub (pinned to b608633a7e)