We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Can't override the type attribute for Phalcon\Forms\Element\Text

When I do:

$email = new Text( 'email' );
$email->setAttribute( 'type', 'email' );
$this->add($email);

It gets rendered as:

<input type="text" id="email" name="email" />

Even though I explicitly set the type attribute to "email". Is there a way to accomplish this without writing my own element class?



1.4k
Accepted
answer
edited May '15

Hi, you have to use Phalcon\Forms\Element\Email instead of Phalcon\Forms\Element\Text

use Phalcon\Forms\Element\Email;
...
$email = new Email( 'email' );
$this->add($email);

Blargh, how did I not fond that in the docs? Thanks jcheron.