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.

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 {%



67.7k
Accepted
answer

if you are using phalcon forms


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

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

Thanks, that works.