{"record":{"id":"92aad45e17a7accf","repo":"phalcon/cphalcon","slug":"the-using-parameter-is-required","errorCode":null,"errorMessage":"The 'using' parameter is required","messagePattern":"The 'using' parameter is required","errorType":"exception","errorClass":"Phalcon\\Tag\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Tag/Select.zep","lineNumber":113,"sourceCode":"            if !fetch emptyText, params[\"emptyText\"] {\n                let emptyText = \"Choose...\";\n            } else {\n                unset params[\"emptyText\"];\n            }\n\n            unset params[\"useEmpty\"];\n        }\n\n        if !fetch options, params[1] {\n            let options = data;\n        }\n\n        if typeof options == \"object\" {\n            /**\n             * The options is a resultset\n             */\n            if unlikely !fetch using, params[\"using\"] {\n                throw new Exception(\"The 'using' parameter is required\");\n            }\n\n            if unlikely (typeof using != \"array\" && typeof using != \"object\") {\n                throw new Exception(\n                    \"The 'using' parameter should be an array\"\n                );\n            }\n        }\n\n        unset params[\"using\"];\n\n        let code = BaseTag::renderAttributes(\"<select\", params) . \">\" . PHP_EOL;\n\n        if useEmpty {\n            /**\n             * Create an empty value\n             */\n            let code .= self::echoOption(emptyValue)","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Tag/Select.zep#L95-L131","documentation":"Tag\\Select::selectField (behind Tag::select() and Tag::selectStatic()) accepts options as an array, a Resultset, or any object. When options is an object (typically an ORM Resultset of models), Phalcon cannot know which model properties map to option value/label, so the 'using' parameter in the params array is mandatory; when fetch params['using'] fails, it throws Phalcon\\Tag\\Exception (\"The 'using' parameter is required\"). Array options never need 'using'.","triggerScenarios":"echo Tag::selectStatic(['categoryId'], Categories::find()); — a Resultset without 'using'; the same via Tag::select([...], $robots); 'using' present in the options/data array instead of the params array, so params['using'] is never found.","commonSituations":"Switching a select from static array options to Model::find() results without adding 'using'; Volt templates like {{ select('id', robots) }} missing the options map; params built dynamically where the 'using' key is dropped.","solutions":["Add 'using' to the first (params) argument: Tag::selectStatic(['categoryId', 'using' => ['id', 'name']], Categories::find())","In Volt: {{ select('categoryId', categories, ['using': ['id', 'name']]) }}","If you meant plain options, pass an array (e.g. Categories::find()->toArray() prepared as value=>label) — arrays need no 'using'"],"exampleFix":"// before\necho \\Phalcon\\Tag::selectStatic(['categoryId'], Categories::find()); // throws\n\n// after\necho \\Phalcon\\Tag::selectStatic(\n    ['categoryId', 'using' => ['id', 'name']],\n    Categories::find()\n);","handlingStrategy":"validation","validationCode":"$params = ['categoryId'];\n\nif (is_object($options)) { // Resultset/object options require 'using'\n    $params['using'] = $params['using'] ?? ['id', 'name'];\n}\n\necho \\Phalcon\\Tag::selectStatic($params, $options);","typeGuard":"function needsUsingParameter($options): bool\n{\n    return is_object($options); // arrays never need 'using'\n}","tryCatchPattern":"try {\n    echo \\Phalcon\\Tag::selectStatic($params, $options);\n} catch (\\Phalcon\\Tag\\Exception $e) {\n    if (str_contains($e->getMessage(), \"'using' parameter is required\")) {\n        $params['using'] = ['id', 'name'];\n        echo \\Phalcon\\Tag::selectStatic($params, $options);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Treat 'using' as mandatory whenever options come from Model::find()/Resultset","Centralize select rendering in a wrapper that injects the using map","Remember array options never need 'using' — only object options do"],"tags":["phalcon","tag","select","orm","forms"],"backgroundTag":"missing-required-parameter","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}