[NFR] HTML5 form elements
I think it will be great if you, guys, implement the HTML5 elements for Tag component, I mean: input[type=email]; input[type=color]; input[type=datetime]; input[type=range]; input[type=tel]; input[type=url]; datalist>options; output; keygen;
You can use the tagHtml function of \Phalcon\Tag. It is a generic function that creates any kind of element. Examples:
// <output> with EOL at the end
$name = 'output';
$params = null;
$selfClose = false;
$onlyStart = true;
$eol = true;
echo Phalcon\Tag::tagHtml($name, $parameters, $selfClose, $onlyStart, $eol);
Input
// <input type='email' /> with EOL at the end
$name = 'input';
$params = array('type' => 'email');
$selfClose = true;
$onlyStart = false;
$eol = true;
echo Phalcon\Tag::tagHtml($name, $parameters, $selfClose, $onlyStart, $eol);
Keygen
// <keygen name="name" challenge="challenge string" keytype="type" keyparams="pqg-params"> with EOL at the end
$name = 'keygen';
$params = array(
'name' => "name",
'challenge' => "challenge string",
"keytype" => "type",
"keyparams" => "pqg-params"
);
$selfClose = true;
$onlyStart = false;
$eol = true;
echo Phalcon\Tag::tagHtml($name, $parameters, $selfClose, $onlyStart, $eol);
Closing - tagHtml supports any HTML5 or other element - even made up ones.
But how add [type=url] in Form? I need validation in Form @niden, @sergeyklay I think this issue can be reopen
namespace My\Awesome\Element;
use Phalcon\Tag;
use Phalcon\Forms\Element;
class Url extends Element
{
public function render(array $attributes = null)
{
return Tag::urlField($this->prepareAttributes($attributes));
}
}