{"record":{"id":"5bba86807f93c54c","repo":"phalcon/cphalcon","slug":"form-name-is-not-registered-in-the-formslocato","errorCode":null,"errorMessage":"Form '{name}' is not registered in the FormsLocator","messagePattern":"Form '(.+?)' is not registered in the FormsLocator","errorType":"exception","errorClass":"Phalcon\\Forms\\Exceptions\\FormNotInLocator","httpStatus":null,"severity":"error","filePath":"phalcon/Forms/FormsLocator.zep","lineNumber":97,"sourceCode":"\n    /**\n     * Returns the named form.\n     *\n     * Without an entity the result is lazily created and cached.\n     * With an entity a fresh form is always produced.\n     *\n     * @param string      $name\n     * @param object|null $entity\n     *\n     * @return Form\n     * @throws Exception\n     */\n    public function get(string name, var entity = null) -> <Form>\n    {\n        var factory, instance;\n\n        if !this->has(name) {\n            throw new FormNotInLocator(name);\n        }\n\n        let factory = this->factories[name];\n\n        if entity !== null {\n            return {factory}(entity);\n        }\n\n        if !fetch instance, this->instances[name] {\n            let instance = {factory}(null);\n            let this->instances[name] = instance;\n        }\n\n        return instance;\n    }\n\n    /**\n     * Returns the factory callable for the given element type.","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Forms/FormsLocator.zep#L79-L115","documentation":"Thrown by Phalcon\\Forms\\FormsLocator::get() when the requested form name has no registered factory. The locator is a closure registry: each form must be registered with set($name, fn(?object $entity) => new Form) or supplied in the constructor's definitions array before get() can resolve it.","triggerScenarios":"Calling $locator->get('login') before $locator->set('login', ...) was ever called; requesting a form name absent from the definitions array passed to new FormsLoader([$definitions]); a typo or case difference between the set() key and the get() key.","commonSituations":"A central form registry in the DI container where the new form class was written but never registered; refactoring form names; registration living in a config file that was not updated in one environment.","solutions":["Register the factory before use: $locator->set('login', fn(?object $entity) => new LoginForm($entity))","Guard the lookup: if ($locator->has('login')) { $form = $locator->get('login'); }","Compare the exact spelling and case of the name passed to get() against the set() or constructor registration"],"exampleFix":"// before\n$form = $locator->get('signup'); // never registered\n\n// after\n$locator->set('signup', fn(?object $entity = null) => new SignUpForm($entity));\n$form = $locator->get('signup');","handlingStrategy":"validation","validationCode":"if ($locator->has($name)) {\n    $form = $locator->get($name, $entity);\n} else {\n    throw new \\RuntimeException(\"Form '{$name}' is not registered in the locator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $form = $locator->get($name, $entity);\n} catch (\\Phalcon\\Forms\\Exceptions\\FormNotInLocator $e) {\n    // fall back to building the form directly\n    $form = new DefaultForm($entity);\n}","preventionTips":["Register all form factories in one composition root so registrations cannot be skipped","Add a startup check that iterates your expected form names and asserts $locator->has($name)","Store form registry keys alongside the form classes (config mapping) instead of duplicating strings"],"tags":["phalcon","forms","locator","registry","service-not-registered"],"backgroundTag":"service-not-registered","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}