cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] HTML5 form elements

Open milchinskiy opened this issue 13 years ago • 4 comments

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;

milchinskiy avatar May 14 '13 20:05 milchinskiy

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);

niden avatar May 15 '13 15:05 niden

Closing - tagHtml supports any HTML5 or other element - even made up ones.

niden avatar May 22 '13 18:05 niden

But how add [type=url] in Form? I need validation in Form @niden, @sergeyklay I think this issue can be reopen

mzf avatar Feb 08 '17 11:02 mzf

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));
	}
}

sergeyklay avatar Feb 08 '17 11:02 sergeyklay