Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



28.9k
Accepted
answer

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



1.4k

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



1.4k
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 ...



1.4k

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