{% load static %}
{% load i18n %}

<!-- Field SCHEMA -  bigset={{ item.bigset }} - is_multi={{ item.is_multi }} -->

{% if item.is_multi %}
<div class="mb-3 row">
<label class="col-form-label col-sm-2">{{ item.displayname }}</label>

<div class="form-check col-sm-10">
{% if item.bigset %}
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}" multiple
  data-cv-select2="ajax-instance"
  data-cv-ajax-url="{% url 'app_data:ajax_instance' %}"
  data-cv-classname="{{ item.dataformat_ext }}"
  data-cv-placeholder="{% translate 'Select items' %}">
{% else %}
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}" multiple
  data-cv-select2="simple">
{% endif %}
    {% for instance in item.value %}
    {% if instance.selected %}<option value="{{ instance.key }}" selected>
      {{ instance.display|default:instance.key }}
    </option>
    {% else %}<option value="{{ instance.key }}">
      {{ instance.display|default:instance.key }}
    </option>{% endif %}
    {% endfor %}
</select>
  {% if item.description %}<div class="form-text">{{ item.description }}</div>{% endif %}
</div>
</div>

{% else %}

<div class="mb-3 row">
<label class="col-form-label col-sm-2">{{ item.displayname }}</label>

<div class="form-check col-sm-10">
{% if item.bigset %}
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}"
  data-cv-select2="ajax-instance"
  data-cv-ajax-url="{% url 'app_data:ajax_instance' %}"
  data-cv-classname="{{ item.dataformat_ext }}"
  data-cv-placeholder="{% translate 'Select items' %}">
{% else %}
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}"
  data-cv-select2="simple">
{% endif %}
    <option value="">---------------------------------</option>
    {% for instance in item.value %}
    {% if instance.selected %}<option value="{{ instance.key }}" selected>
      {{ instance.display|default:instance.key }}
    </option>
    {% else %}<option value="{{ instance.key }}">
      {{ instance.display|default:instance.key }}
    </option>{% endif %}
    {% endfor %}
</select>
  {% if item.description %}<div class="form-text">{{ item.description }}</div>{% endif %}
</div>
</div>

{% endif %}


