{% if not widget.has_selected %} {{ widget.attrs.placeholder }} {% else %} {% for _, options, _ in widget.optgroups %} {% for option in options %} {% if option.selected %} {% block show_selected %} {{ option.label }}, {% endblock show_selected %} {% endif %} {% endfor %} {% endfor %} {% endif %}
{% block field_template %} {# Hidden input to ensure that a value always is included in the form submission, even when no options are selected #} {% include "django/forms/widgets/multiple_input.html" %} {% endblock field_template %}