viewflow / django-material

Material Design for Django
http://viewflow.io/
BSD 3-Clause "New" or "Revised" License
2.49k stars 424 forks source link

django_checkboxselectmultiple.html is not support grouped choices. #436

Closed nikolaysm closed 3 years ago

nikolaysm commented 6 years ago

Maybe we can use something like the code below:

**{% part field group_columns asvar 'group_columns' %}12{% endpart %}**
{% part field control %}
    <div class="row">
        {% for group, items in bound_field|select_options %}
            **{% if group %}<div class="col l{{ group_columns }}"><h5>{{ group }}</h5>{% endif %}**
            {% for col_span, choices in items|split_choices_by_columns:columns %}<div class="col l{{ col_span }}">
                {% for choice, value, selected, position in choices %}
                    <div class="checkbox" id="id_{{ wizard.form.connectors.html_name }}"><label>
                        <input{% attrs bound_field 'widget' default field.widget.attrs %}
                            id="id_{{ bound_field.html_name }}_{{ position }}"
                            name="{{ bound_field.html_name }}"
                            type="checkbox"
                            {% if bound_field.errors %}class="invalid"{% endif %}
                            value="{{ value|unlocalize }}"
                            {% if field.disabled %}disabled{% endif %}
                            {% if selected %}checked{% endif %}
                        {% endattrs %}/>
                        <span for="id_{{ bound_field.html_name }}_{{ position }}">{{ choice }}</span>
                    </label></div>
                {% endfor %}
            </div>{% endfor %}
            **{% if group %}</div>{% endif %}**
        {% endfor %}
    </div>
{% endpart %}
kmmbvnr commented 3 years ago

Thank you!