{"record":{"id":"29c02a87c1d61e37","repo":"phalcon/cphalcon","slug":"form-schema-definition-at-index-index-is-missing-29c02a","errorCode":null,"errorMessage":"Form schema definition at index {index} is missing required key \"name\"","messagePattern":"Form schema definition at index (.+?) is missing required key \"name\"","errorType":"exception","errorClass":"Phalcon\\Forms\\Exceptions\\SchemaEntryMissingKey","httpStatus":null,"severity":"error","filePath":"phalcon/Forms/Loader/ArrayLoader.zep","lineNumber":68,"sourceCode":"\n    /**\n     * @param mixed $definition\n     * @param int   $index\n     *\n     * @throws Exception\n     */\n    protected function validateDefinition(var definition, int index) -> void\n    {\n        if typeof definition !== \"array\" {\n            throw new SchemaEntryNotArray(index);\n        }\n\n        if !isset definition[\"type\"] || empty definition[\"type\"] {\n            throw new SchemaEntryMissingKey(index, \"type\");\n        }\n\n        if !isset definition[\"name\"] || empty definition[\"name\"] {\n            throw new SchemaEntryMissingKey(index, \"name\");\n        }\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":72,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Forms/Loader/ArrayLoader.zep#L50-L72","documentation":"ArrayLoader::validateDefinition() requires every definition array to carry a non-empty 'name' key, which becomes the element's name inside the form. A definition missing 'name', or with an empty/falsy value, throws SchemaEntryMissingKey reporting the index and the key 'name'.","triggerScenarios":"A schema entry like ['type' => 'text'] with no 'name' key; an entry with 'name' => '' (empty string is rejected by the empty() check); a typo such as 'label' used where 'name' was intended.","commonSituations":"Copy-pasted schema blocks where the name line was dropped; dynamically generated definitions whose name variable is empty for some rows.","solutions":["Add a non-empty 'name' key to the entry at the reported index, e.g. ['type' => 'text', 'name' => 'email']","When generating definitions, guard with isset($def['name']) && $def['name'] !== ''","Use the index in the exception message to locate the exact offending entry"],"exampleFix":"// before\n[\n  ['type' => 'text']\n]\n\n// after\n[\n  ['type' => 'text', 'name' => 'email']\n]","handlingStrategy":"validation","validationCode":"foreach ($definitions as $index => $definition) {\n    if (!isset($definition['name']) || $definition['name'] === '') {\n        throw new \\InvalidArgumentException(\n            \"Schema entry {$index} is missing a non-empty 'name'\"\n        );\n    }\n}\n\n$defs = (new \\Phalcon\\Forms\\Loader\\ArrayLoader($definitions))->load();","typeGuard":"function hasValidName(array $definition): bool\n{\n    return isset($definition['name'])\n        && is_string($definition['name'])\n        && $definition['name'] !== '';\n}","tryCatchPattern":"try {\n    $defs = (new \\Phalcon\\Forms\\Loader\\ArrayLoader($definitions))->load();\n} catch (\\Phalcon\\Forms\\Exceptions\\SchemaEntryMissingKey $e) {\n    // message names index and key ('name'); fix the file at that index\n    $logger->error($e->getMessage());\n    throw $e;\n}","preventionTips":["Validate schema files in CI by loading them through ArrayLoader as a test","When generating entries from entity metadata, skip or fail loudly when the name source is empty","Keep an example schema file that always passes as a reference for required keys"],"tags":["phalcon","forms","schema","missing-key","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}