{"record":{"id":"d2b5a4c9fb1b10c2","repo":"octobercms/october","slug":"a-widget-class-name-name-has-not-been-registere","errorCode":null,"errorMessage":"A widget class name ':name' has not been registered","messagePattern":"A widget class name ':name' has not been registered","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/traits/WidgetMaker.php","lineNumber":43,"sourceCode":"            : $this;\n\n        return $controller->widget->{$name} ?? null;\n    }\n\n    /**\n     * makeWidget object with the supplied configuration file.\n     * @param string $class\n     * @param array $widgetConfig\n     * @return \\Backend\\Classes\\WidgetBase\n     */\n    public function makeWidget($class, $widgetConfig = [])\n    {\n        $controller = property_exists($this, 'controller') && $this->controller\n            ? $this->controller\n            : $this;\n\n        if (!class_exists($class)) {\n            throw new SystemException(Lang::get('backend::lang.widget.not_registered', [\n                'name' => $class\n            ]));\n        }\n\n        return new $class($controller, $widgetConfig);\n    }\n\n    /**\n     * makeFormWidget object with the supplied form field and widget configuration.\n     * The fieldConfig is a field name, an array of config or a FormField object.\n     * @param string $class\n     * @param mixed $fieldConfig\n     * @param array $widgetConfig\n     * @return \\Backend\\Classes\\FormWidgetBase\n     */\n    public function makeFormWidget($class, $fieldConfig = [], $widgetConfig = [])\n    {\n        $controller = property_exists($this, 'controller') && $this->controller","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/traits/WidgetMaker.php#L25-L61","documentation":"WidgetMaker::makeWidget() instantiates a backend widget class by name and throws this localized error (backend::lang.widget.not_registered) when class_exists($class) fails. Despite the wording, nothing needs runtime 'registration' — the fully-qualified class name simply must be autoloadable. Controllers use this to build Search, Toolbar and Filter widgets, so a bad name breaks the whole controller view.","triggerScenarios":"$this->makeWidget('Backend\\Widgets\\Seach') (typo); $this->makeWidget($config->widget) where the config supplies an empty, aliased, or misspelled name; a plugin widget namespace that does not match the file path.","commonSituations":"Widget class strings coming from YAML/PHP config files with typos or wrong case; missing `use` imports so short names resolve incorrectly; a plugin that failed to boot so its classes never load; stale composer autoload after plugin changes.","solutions":["Use the ::class constant of an imported class instead of a hand-typed string: $this->makeWidget(\\Backend\\Widgets\\Search::class).","Compare the exact string from the error message against the real class name for typos, case, and namespace segments.","Ensure the defining plugin is installed and run composer dump-autoload.","If the name comes from config, validate it against known widget classes before calling makeWidget()."],"exampleFix":"// before\n$widget = $this->makeWidget('Backend\\\\Widgets\\\\Seach');\n\n// after\nuse Backend\\Widgets\\Search;\n\n$widget = $this->makeWidget(Search::class);","handlingStrategy":"validation","validationCode":"$widgetClass = $config['widget'] ?? null;\nif (!$widgetClass || !class_exists($widgetClass)) {\n    throw new InvalidArgumentException('Unknown widget class: ' . var_export($widgetClass, true));\n}\n$widget = $this->makeWidget($widgetClass);","typeGuard":"function isBackendWidgetClass(string $class): bool\n{\n    return class_exists($class) && is_a($class, \\Backend\\Classes\\WidgetBase::class, true);\n}","tryCatchPattern":"try {\n    $widget = $this->makeWidget($class);\n} catch (SystemException $e) {\n    // class_exists failed - the config referenced an unloadable widget\n    Log::error('makeWidget failed', ['class' => $class, 'error' => $e->getMessage()]);\n    abort(404, 'This page is misconfigured.');\n}","preventionTips":["Use WidgetClass::class constants instead of hand-typed strings","Validate widget names coming from YAML config before calling makeWidget()","Keep composer autoload fresh after plugin changes"],"tags":["widget","class-not-found","autoloading","backend","php"],"backgroundTag":"class-not-found","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}