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

Putting IF Condition into text_field value

How i can putting IF Condition into a text_field value using volt

I tried this:

{{ text_field('name', 'value': {% if city.name <> "" %} {{ city.name }} {% endif %}) }}

But not work, display a syntax error:

Syntax error, unexpected token {%



85.5k
Accepted
answer

if you are using phalcon forms


$fields = new Text();
$this->add($field);

if (whatever){
    $field->setDefault("asdasda");
}

Thanks, that works.