Description
Describe the bug
Creating an instance of a Input form element (Hidden for example), there is no way for this to relate to the doctype of the document and render with or without closing slash
To Reproduce
Tag::setDocType(Tag::HTML5);
$hidden = new Hidden('test');
echo $hidden . PHP_EOL;
Tag::setDocType(Tag::XHTML5);
$hidden2 = new Hidden('test2');
echo $hidden2 . PHP_EOL;
Expected behavior
should output
<input type="hidden" id="test" name="test">
<input type="hidden" id="test2" name="test2" />
Actual behavior
outputs
<input type="hidden" id="test" name="test" />
<input type="hidden" id="test2" name="test2" />
Details
- Phalcon version: 5.9.3
- PHP Version: 8.4.8
- Operating System:
- Installation type: Ubuntu
- Zephir version (if any):
- Server: Nginx
Additional context
this used to work in older version of phalcon as the Tag::setDocType(Tag::HTML5) was used when rendering tags but the phalcon/Html/Helper/Input/AbstractInput.zep __toString method now hardcodes the closing slash...
it appears that the Tag.zep code still does this type of thing correctly
if self::documentType > self::HTML5 {
let code .= " />" . PHP_EOL;
} else {
let code .= ">" . PHP_EOL;
}
but the rendering of inputs is not using this anymore?
this was reported when validating generated output via https://validator.w3.org/