octobercms/october · error · SystemException

The model class :model must define a method :method()…

Error message

The model class :model must define a method :method() returning options for the ':filter' filter.

What it means

Thrown by FilterScope::getOptionsFromModelAsString when a scope's options string references an instance method on the model but that method does not exist on the model class. The filter YAML names a method the model must implement to supply option values, and is_callable/the method lookup fails.

Solutions

  1. Implement the named public method on the model class returning an array of options
  2. Correct the method name spelled in the filter definition's options setting
  3. If options come from a list or array, use the array syntax or a static ClassName::method reference instead
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/backend/classes/FilterScope.php:68 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/a66778c42a6db9f2. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/classes/FilterScope.php:68

        if (
            strpos($methodName, '::') !== false &&
            ($staticMethod = explode('::', $methodName)) &&
            count($staticMethod) === 2 &&
            is_callable($staticMethod)
        ) {
            $scopeOptions = $staticMethod($model, $this);

            if (!is_array($scopeOptions)) {
                throw new SystemException(Lang::get('backend::lang.field.options_static_method_invalid_value', [
                    'class' => $staticMethod[0],
                    'method' => $staticMethod[1]
                ]));
            }
        }
        // Calling via $model->method
        else {
            if (!$this->objectMethodExists($model, $methodName)) {
                throw new SystemException(Lang::get('backend::lang.filter.options_method_not_exists', [
                    'model' => get_class($model),
                    'method' => $methodName,
                    'filter' => $this->fieldName
                ]));
            }

            $scopeOptions = $model->$methodName($this);
        }

        return $scopeOptions;
    }

    /**
     * applyScopeMethodToQuery
     */
    public function applyScopeMethodToQuery($query, $methodName = null)
    {
        if (!$methodName) {

View on GitHub (pinned to b608633a7e)