{"record":{"id":"382c07e265b7f34c","repo":"octobercms/october","slug":"the-model-class-model-must-define-a-method-metho-382c07","errorCode":null,"errorMessage":"The model class :model must define a method :method() returning html color HEX codes for the ':field' form field.","messagePattern":"The model class :model must define a method :method\\(\\) returning html color HEX codes for the ':field' form field\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/backend/formwidgets/ColorPicker.php","lineNumber":134,"sourceCode":"        $this->vars['showInput'] = $this->showInput;\n        $this->vars['readOnly'] = $this->readOnly;\n        $this->vars['disabled'] = $this->disabled;\n        $this->vars['isCustomColor'] = !in_array($value, $availableColors);\n    }\n\n    /**\n     * getAvailableColors as a list of available colors.\n     */\n    protected function getAvailableColors(): array\n    {\n        $availableColors = $this->availableColors;\n        if (is_array($availableColors)) {\n            return $availableColors;\n        }\n\n        if (is_string($availableColors) && strlen($availableColors)) {\n            if (!$this->model->methodExists($availableColors)) {\n                throw new ApplicationException(Lang::get('backend::lang.field.colors_method_not_exists', [\n                    'model' => get_class($this->model),\n                    'method' => $availableColors,\n                    'field' => $this->formField->fieldName\n                ]));\n            }\n\n            // @deprecated just pass form field here -sg\n            return (array) $this->model->{$availableColors}(\n                $this->formField->fieldName,\n                $this->formField->value,\n                $this->formField->config\n            );\n        }\n\n        return [];\n    }\n\n    /**","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/formwidgets/ColorPicker.php#L116-L152","documentation":"Thrown by ColorPicker::getAvailableColors when availableColors is a string naming a model method but that method is not defined on the model class. The widget expects the method to return an array of hex color codes; the failure is the missing method itself, before any return-type check.","triggerScenarios":"Thrown at modules/backend/formwidgets/ColorPicker.php:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the named method on the model returning an array of HEX color strings","Correct the availableColors value in the field config to an existing method name","Pass the colors directly as an array in the field configuration instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","contentChangedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}