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

How I should use radio_field?

Here is my code:

<div id='{{ admin }}' class='radio'>
    {% for option in options %}
    <label class='radio-inline'>
        {% if user is defined and
            usuario.admin is sameas(option['value']) %}
            {{ radio_field('admin', 'id': null, 'value': option['value'], 'checked': true)}}
        {% else %}
            {{ radio_field('admin', 'id': null, 'value': option['value'])}}
        {% endif %}
        {{ option['text'] }}
    </label>
    {% endfor %}
</div>

Now, the problem is that, when the else occurs, the checked dissapears from the radio that has it (deletes it). And if I try setting his checked to false, it just selects the last created radio button. Why?



33.8k
Accepted
answer

Ok, it was cause of sameas. I had to use == (my my).