{"record":{"id":"7180357c88432f02","repo":"phalcon/cphalcon","slug":"parameter-using-requires-two-values","errorCode":null,"errorMessage":"Parameter 'using' requires two values","messagePattern":"Parameter 'using' requires two values","errorType":"exception","errorClass":"Phalcon\\Tag\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Tag/Select.zep","lineNumber":262,"sourceCode":"    /**\n     * Generate the OPTION tags based on a resultset\n     */\n    private static function optionsFromResultset(\n        <ResultsetInterface> resultset,\n        var using,\n        var value,\n        string closeOption\n    ) -> string\n    {\n        var code, escaper, executed, params, option, usingZero, usingOne,\n            optionValue, optionText, strValue, strOptionValue;\n\n        let code = \"\";\n        let params = null;\n\n        if typeof using == \"array\" {\n            if unlikely count(using) != 2 {\n                throw new Exception(\"Parameter 'using' requires two values\");\n            }\n\n            let usingZero = self::toStringValue(using[0]),\n                usingOne  = self::toStringValue(using[1]);\n        }\n\n        let escaper = <EscaperInterface> BaseTag::getEscaperService();\n\n        for option in iterator(resultset) {\n            if typeof using == \"array\" {\n                if typeof option == \"object\" {\n                    if method_exists(option, \"readAttribute\") {\n                        let optionValue = option->readAttribute(usingZero);\n                        let optionText = option->readAttribute(usingOne);\n                    } else {\n                        let optionValue = option->{usingZero};\n                        let optionText = option->{usingOne};\n                    }","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Tag/Select.zep#L244-L280","documentation":"Phalcon\\Tag\\Select builds <select> options from a Phalcon\\Mvc\\Model resultset. The 'using' parameter names the two fields read from every row: the first becomes the <option value>, the second the visible text (optionsFromResultset, phalcon/Tag/Select.zep:262). When 'using' is an array it must contain exactly two entries, otherwise the helper throws Phalcon\\Tag\\Exception before rendering anything.","triggerScenarios":"Calling Tag::select() / Tag::selectStatic() / Tag\\Select::selectField() with a resultset (or any object) as data and a 'using' array whose count() != 2, e.g. ['using' => ['id']] or ['using' => ['id', 'name', 'status']].","commonSituations":"Adding a third column to get extra attributes into each option; renaming model fields while the template keeps stale 'using' entries; copy-pasting a select definition and trimming one field; note that a non-array 'using' (e.g. string) is rejected earlier with a different message ('The using parameter should be an array').","solutions":["Set 'using' to exactly two field names: ['using' => ['id', 'name']] — first element is the option value, second is the label.","If you need more per-option data, map the resultset to key=>text pairs yourself and pass that array as the select data (use Tag::selectStatic).","Verify both field names actually exist on each row; they are read via readAttribute() or property access on objects, or as array keys on array rows."],"exampleFix":"// before\nTag::select(['roleId', $roles, 'using' => ['id', 'name', 'status']]);\n// throws: Parameter 'using' requires two values\n\n// after\nTag::select(['roleId', $roles, 'using' => ['id', 'name']]);","handlingStrategy":"validation","validationCode":"$using = $params['using'] ?? null;\nif (is_array($using) && count($using) !== 2) {\n    throw new InvalidArgumentException(\"Tag::select 'using' must have exactly 2 fields [value, text]\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    echo Tag::select(['roleId', $roles, 'using' => $using]);\n} catch (\\Phalcon\\Tag\\Exception $e) {\n    $logger->error('Select helper misconfigured: ' . $e->getMessage());\n    echo '<select name=\"roleId\"></select>';\n}","preventionTips":["Treat 'using' as a strict [valueField, textField] pair in code review of templates.","Centralize select-building in view helpers/ partials so the pair is defined in one place.","Add a smoke test rendering every select used by the app with a fixture resultset."],"tags":["phalcon","tag","select","html-helper","resultset","view"],"backgroundTag":"invalid-view-helper-arguments","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}