{#
 # This file is part of the CRUDlex package.
 #
 # (c) Philip Lehmann-Böhm <philip@philiplb.de>
 #
 # For the full copyright and license information, please view the LICENSE
 # file that was distributed with this source code.
 #}

{% include crud.getTemplate('template', 'fieldLabel', crudEntity) with {
    field: field,
    definition: crudData.getDefinition(),
    annotations: annotations
} only %}
<select class="form-control many-crudlex" multiple="multiple" id="{{ field }}" name="{{ fieldNamePrefix ~ field }}[]">
    {% set values = crudData.getIdToNameMap(crudData.getDefinition().getSubTypeField(field, 'many', 'entity'), crudData.getDefinition().getSubTypeField(field, 'many', 'nameField')) %}
    {% for id, manyValue in values %}
        <option value="{{ id }}" {% if value and id in value|crudlex_arrayColumn('id') %}selected="selected" {% endif %}>{{ manyValue }}</option>
    {% endfor %}
</select>
