{% load crispy_forms_filters %}
{% load l10n %}

<select
  class="select w-full{% if field.errors %} select-error{% endif %}"
  name="{{ field.html_name }}"
  id="{{ field.id_for_label }}"
  {% if field.field.widget.allow_multiple_selected %}multiple{% endif %}
  {{ field.field.widget.attrs|flatatt }}>
  {% for group, options, index in field|optgroups %}
    {% if group %}<optgroup label="{{ group }}">{% endif %}
    {% for option in options %}
      {% include "daisyui/layout/select_option.html" with value=option.value label=option.label selected=option.attrs.selected %}
    {% endfor %}
    {% if group %}</optgroup>{% endif %}
  {% endfor %}
</select>
