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

View helper Multi checkbox

Hi, how do we implement multiselect checkbox with Volt ?

Thank you !

You can use the Element::setUserOption() method to set the values and the specific parameters you want to use. In Volt template, you have to generate it by the list of your values (through a loop). Sth like :


{% set boolIsRadio = objField.getUserOption('is_unique') %}
{% set arrayCheckMultiple = objField.getUserOption('multiple') %}

{% for strCheckKeyName, strLabel in arrayCheckMultiple %}
             {% set strCurrentFieldName = '[' ~ strCheckKeyName ~ ']' %}
             <label>
            {% if boolIsRadio %}
               {{ radio_field(objField) }}
            {% else %}
                {{ check_field(objField, 'name':strCurrentFieldName) }}
            {% endif %}
            {{ strLabel }}
            </label>
{% endfor %}

(it assumes here you are looping on the form's fields)