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

Phalcon\Tag::setDefault 无效

in volt file : .... <input type="text" id="iput2" name="iput2" class="span6" size="30" /> ....

in Controller/Action: Phalcon\Tag::setDefault("iput2","test");

但是页面显示时没有值。。。。



51.2k
Accepted
answer
edited Sep '14

You can use something like this:

In controller:

        $tag = new \Phalcon\Forms\Element\Text('iput2');
        $tag->setDefault('test');

        $this->view->iput2 = $tag;

In view (volt):

    {{ iput2.render() }}

Or with tags:

In controller:

    \Phalcon\Tag::setDefault("ipu2", "test");

In volt:

    {{ text_field("ipu2") }}