<div class="{% if error %}{{ field.error_class }}{% endif %}">
    <select id="{{ field.id }}"
            name="{{ field.id }}"
            data-allow-clear="true"
            data-placeholder="{{ _('Select a %(label)s', label=field.label) }}"
            class="field-enum form-control form-select {% if error %}{{ field.error_class }}{% endif %} generic-emb-select"
            {% if field.disabled %}disabled{% endif %}
            {% if field.select2 %}data-role="select2"{% endif %}
            onchange="onchange_generic_emb_select(this)">
        {% if not field.required %}
            <option></option>
        {% endif %}
        {% for doc_name in field.embedded_doc_fields.keys() %}
            <option value="{{ doc_name }}" {{ 'selected' if doc_name == data["__doc_name__"] else '' }}>{{ doc_name }}
            </option>
        {% endfor %}
    </select>
    <fieldset id="{{ field.fieldset_id }}" class="form-fieldset">
        {% for field in field.get_fields_list(request, "", action) %}
        <div id="{{ field.id }}.div"
             class="form-group row mb-3">
            <label class="col-3 col-form-label {% if field.required %}required{% endif %}"
                   for="{{ field.id }}">{{ field.label }}</label>
            <div class="col">
                {% if not error or error is mapping %}
                {% set item_data= (data[field.name] if data else None) %}
                {% with data=item_data, error=error.get(field.name, None) if error else None %}
                {% include field.form_template %}
                {% endwith %}
                {% else %}
                {% set error= None %}
                {% include field.form_template %}
                {% endif %}
            </div>
        </div>
        {% endfor %}
    </fieldset>
    {% if field.help_text %}
    <small class="form-hint mt-2">{{ field.help_text }}</small>
    {% endif %}
</div>
{% include "forms/_error.html" %}
