<!-- USER format -->
{% load static %}
{% load i18n %}

<!-- # value: [ { 'key':'keyname' , 'selected':True/False }, ...    ]  -->

{% 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">
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}" multiple
  data-cv-select2="ajax-user"
  data-cv-ajax-url="{% url 'app_user:ajax_user' %}"
  data-cv-placeholder="{% translate 'Select users' %}">
    {% for instance in item.value %}
    {% if instance.selected %}<option value="{{ instance.key }}" selected label="uuuuuuu">{{instance.key}} ({{ instance.display }})</option>
    {% else %}<option value="{{ instance.key }}" label="vvvvvvvv">{{instance.key}} ({{ instance.display }})</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">
<select class="form-check col-sm-10" name="{{ item.fieldname }}" id="id_{{item.fieldname}}"
  data-cv-select2="ajax-user"
  data-cv-ajax-url="{% url 'app_user:ajax_user' %}"
  data-cv-placeholder="{% translate 'Select users' %}">
    <option value="">----------------------</option>
    {% for instance in item.value %}
    {% if instance.selected %}<option value="{{ instance.key }}" selected>{{instance.key}} ({{ instance.display }})</option>
    {% else %}<option value="{{ instance.key }}">{{instance.key}} ({{ instance.display }})</option>{% endif %}
    {% endfor %}
</select>
  {% if item.description %}<div class="form-text">{{ item.description }}</div>{% endif %}
</div>

</div>


{% endif %}


