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

Proper way to use getter/setter in form

I am able to use a model.getter in my volt form like so: {{ model.getMyDate() }} but what is the proper way to do this with the tags and forms?

In my form I create a text input like so:

       $startDate = new Text('startDate', array(
            'placeholder' => 'Start Date',
            'id' => 'start_date',
            'class' => 'form-control'
        ));

        $this->add($startDate);

Then in my volt view I am rendering it:

{{ form.render("startDate") }}

Since this is no longer attached directly to a public property of my model but needs to attached to the getter, what is the best way to do that?

How about the setDefault when you are setting up the new Text?

\Phalcon\Tag::setDefault('startDate', $model->getMyDate())

Bingo. Thank you.