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

HTML5 like form input fields.

How can I produce HTML5 like form input fields using textField() helper? Now I get: <input type="text" size="30" name="price" id="price" value="" />

And I would like to get: <input type="text" size="30" name="price" id="price" value="">

Do I have to set something somewhere?

I know that tagHtml() can produce valid HTML5 like tag, by setting 3rd argument to false.



40.8k
Accepted
answer

Use before Tag::textField() <?php \Phalcon\Tag::setDoctype(\Phalcon\Tag::HTML5); ?>



2.2k

I see in other post that you use tag registerd in DI then you should use <?php $this->tag->setDoctype(\Phalcon\Tag::HTML5); ?>



2.2k
edited Mar '14

Hmm... I am not. This was my first post, and the other one is about documentation bug, and that is it.

And what I did now is:

Config:

return new \Phalcon\Config(array(
    /** ... */
    'tag' => array(
        'doctype' => \Phalcon\Tag::HTML5
    )
));

And in bootstrap file:

try {

    /**
     * Read the configuration
     */
    $config = include __DIR__ . "/../app/config/config.php";

    /**
     * Setting doctype in tag
     */
    \Phalcon\Tag::setDocType($config->tag->doctype);

     /** ... */
} catch (\Exception $e) {
    echo $e->getMessage();
}

Better to use \Phalcon\Tag::setDoctype(\Phalcon\Tag::HTML5); in BaseController.php in initialize(), but if you want it in bootstrap ...



2.2k

You are most probably right. This is my first day with Phalcon, and I am still getting to know it. Thanks!