{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_forms') }}
{{ attach_library('ui_patterns/form-form.form_lib') }}

{# VARIABLES #}
<select {{ attributes.addClass('custom-select form-select') }}>
  {% for option in options %}
    {% if option.type == 'optgroup' %}
      <optgroup label="{{ option.label }}">
        {% for sub_option in option.options %}
          <option value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
        {% endfor %}
      </optgroup>
    {% elseif option.type == 'option' %}
      <option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
    {% endif %}
  {% endfor %}
</select>
