phalcon/cphalcon · error · Phalcon\Tag\Exception
Parameter 'using' requires two values
Error message
Parameter 'using' requires two values
What it means
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.
Source
Thrown at phalcon/Tag/Select.zep:262
/**
* Generate the OPTION tags based on a resultset
*/
private static function optionsFromResultset(
<ResultsetInterface> resultset,
var using,
var value,
string closeOption
) -> string
{
var code, escaper, executed, params, option, usingZero, usingOne,
optionValue, optionText, strValue, strOptionValue;
let code = "";
let params = null;
if typeof using == "array" {
if unlikely count(using) != 2 {
throw new Exception("Parameter 'using' requires two values");
}
let usingZero = self::toStringValue(using[0]),
usingOne = self::toStringValue(using[1]);
}
let escaper = <EscaperInterface> BaseTag::getEscaperService();
for option in iterator(resultset) {
if typeof using == "array" {
if typeof option == "object" {
if method_exists(option, "readAttribute") {
let optionValue = option->readAttribute(usingZero);
let optionText = option->readAttribute(usingOne);
} else {
let optionValue = option->{usingZero};
let optionText = option->{usingOne};
}View on GitHub (pinned to b7419de9cd)
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.
Example fix
// before Tag::select(['roleId', $roles, 'using' => ['id', 'name', 'status']]); // throws: Parameter 'using' requires two values // after Tag::select(['roleId', $roles, 'using' => ['id', 'name']]);
Defensive patterns
Strategy: validation
Validate before calling
$using = $params['using'] ?? null;
if (is_array($using) && count($using) !== 2) {
throw new InvalidArgumentException("Tag::select 'using' must have exactly 2 fields [value, text]");
} Try / catch
try {
echo Tag::select(['roleId', $roles, 'using' => $using]);
} catch (\Phalcon\Tag\Exception $e) {
$logger->error('Select helper misconfigured: ' . $e->getMessage());
echo '<select name="roleId"></select>';
} Prevention
- 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.
When it happens
Trigger: 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']].
Common situations: 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').
Related errors
- Resultset returned an invalid value
- The 'using' parameter requires exactly two values
- Resultset returned an invalid value
- {message}
- The 'using' parameter is required
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/7180357c88432f02.
Report an issue: GitHub.