{"record":{"id":"5d216bb6d90f7201","repo":"phalcon/cphalcon","slug":"value-at-index-key-type-type-cannot-be-r-5d216b","errorCode":null,"errorMessage":"Value at index: '{key}' type: '{type}' cannot be rendered","messagePattern":"Value at index: '(.+?)' type: '(.+?)' cannot be rendered","errorType":"exception","errorClass":"Phalcon\\Tag\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Tag.zep","lineNumber":1004,"sourceCode":"            }\n        }\n\n        for key, value in attributes {\n            if !isset attrs[key] {\n                let attrs[key] = value;\n            }\n        }\n\n        let escaper = <EscaperInterface> self::getEscaper(attributes);\n\n        unset attrs[\"escape\"];\n\n        let attrParts = [];\n\n        for key, value in attrs {\n            if typeof key == \"string\" && value !== null {\n                if unlikely (typeof value == \"array\" || typeof value == \"resource\") {\n                    throw new Exception(\n                        \"Value at index: '\" . key . \"' type: '\" . gettype(value) . \"' cannot be rendered\"\n                    );\n                }\n\n                if escaper {\n                    let escaped = escaper->attributes(value);\n                } else {\n                    let escaped = value;\n                }\n\n                let attrParts[] = key . \"=\\\"\" . escaped . \"\\\"\";\n            }\n        }\n\n        if empty attrParts {\n            return code;\n        }\n","sourceCodeStart":986,"sourceCodeEnd":1022,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Tag.zep#L986-L1022","documentation":"When Phalcon\\Tag renders an attribute list, every string key with a non-null value becomes a key=\"value\" pair. PHP arrays and resources have no meaningful string form, so an attribute value of either type throws Phalcon\\Tag\\Exception (\"Value at index: '{key}' type: '{type}' cannot be rendered\"), with {type} from gettype(). Only these two types are rejected — scalars pass (objects survive if they stringify during concatenation).","triggerScenarios":"Tag::textField(['name' => 'email', 'class' => ['form-control', 'w-100']]) — array attribute; a file/stream handle ending up in an attribute array; merging structured domain data into params so extra keys become attributes.","commonSituations":"Building 'class' or 'data-*' attributes as arrays out of convenience; passing whole config/request arrays as tag params expecting unknown keys to be ignored.","solutions":["Flatten list attributes yourself: 'class' => implode(' ', $classes)","Filter out resource values before rendering","Map domain data to an explicit scalar-only attribute whitelist instead of passing raw arrays"],"exampleFix":"// before\necho \\Phalcon\\Tag::textField(['name' => 'email', 'class' => ['form-control', 'w-100']]);\n\n// after\necho \\Phalcon\\Tag::textField([\n    'name'  => 'email',\n    'class' => implode(' ', ['form-control', 'w-100']),\n]);","handlingStrategy":"validation","validationCode":"$attributes = array_filter($attributes, function ($value) {\n    return !is_resource($value);\n});\n\n$attributes = array_map(function ($value) {\n    return is_array($value) ? implode(' ', $value) : $value;\n}, $attributes);\n\necho \\Phalcon\\Tag::textField($attributes);","typeGuard":"function isRenderableAttributeValue($value): bool\n{\n    return null === $value || (!is_array($value) && !is_resource($value));\n}","tryCatchPattern":null,"preventionTips":["Implode list-like attributes (class, rel, data-*) yourself before passing them","Map domain data to an explicit scalar-only attribute whitelist at the boundary","Never pass file handles, Resultsets, or decoded nested arrays directly as tag params"],"tags":["phalcon","tag","html-attributes","type-validation"],"backgroundTag":"invalid-attribute-value-type","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}