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 volt engine with getters and setters

I want try this framework, but i have a problem. i am create a application via phalcon-dev-tools

phalcon project phalcon after this i create table users with 2 field = id, login

then

phalcon scaffold --table-name=users --get-set --force --template-engine=volt Model with protected attribute with public methods - its okey

in volt {{ user.id }} return null, because its try to ger property id not method getId()

why?

ps. phalcon 1.2.1

Are you setting the user object in your view?

// In controller
$this->view->setVar('user', User);


918

yes,

$this->view->setVar('page', $paginator->getPaginate());

it is default controller and template generated from devtools



23

I have a same problem. Table 'topics' has fields 'id' and 'text'.

My model is:

class Topics extends \Phalcon\Mvc\Model
{
    protected $id;
    protected $text;
    //...
    public function getId()
    {
        return $this->id;
    }

    public function getText()
    {
        return $this->text;
    }
    //...

in controller I wrote:

    $this->view->first_topic = Topics::findFirst();

and in volt template:

 1: {{ first_topic.text }} <br>
 2: <?php echo $first_topic->text; ?> <br>
 3: {{ first_topic.getText() }} <br>
 4: <?php echo $first_topic->getText(); ?> <br>

as result I have

 1: 
 2: 
 3: First topic
 4: First topic

P.S. I'm using version 1.2.3. from github and php 5.4.9