We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Tag in Volt: Conditional disabled attribute

How to achieve the next:

{{ radio_field(name, "value": 1, "disabled": "") }}

But I need the "disabled" to be conditional, the php equivalent is:

<?php $this->tag->radioField([$name, "value" => 1] + $condition ? ["disabled"=> ""] : []) ?>

I cannot find any method like setDisabled in the tag, similar to setDefault or anything, is there a way to achieve this in volt? or should I keep the php line?

edited Sep '16

Take a look at my example. It does not use Phalcon/Tag.

<input type='radio' value="{{ session.id }}" {% if session.available == 0 %}disabled{%endif%} {% if session.id == client.id %}selected{% endif %}>{{ session.data }}

But try with this radio_field volt tag helper syntax:

{{ radio_field('gender', 'value':'female', {% if setCondition is not empty %}disabled{% endif %}) }}

edited Oct '16

Phalcon\Mvc\View\Exception: Syntax error, unexpected token {% in ....

I don't think we can nest opening tags in volt.

Apparently Volt is not prod ready, it is still quite leaky layer :( we still have to go back to php(as I did) or html (as you did) to achieve nice things.