{% set id = id|default('select-id') %}
{% set name = name|default('select') %}
{% set label = label|default('Select label') %}
{% set options = options|default([
{
"label": "",
"value": "",
"selected": true,
"disabled": true
}, {
label: 'Option 1',
value: '1'
}, {
label: 'Option 2',
value: '2'
}]) %}
{% extends "includes/form_elements/form-control.html.twig" %}
{% block input %}
<select class="form-select form-control {{ (errors|length > 0) ? 'is-invalid' : '' }} {{ attribute(classNames, 'input') }}"
{% for key, value in inputAttributes|default([]) %}
{{ key }}="{{ value }}"
{% endfor %}
>
{% for option in options %}
{% set optionClassName = option.className|default(option.class|default('')) %}
<option class="{{ optionClassName }}" value="{{ option.value|default('') }}"
{{ option.selected|default(false) ? 'selected' : null }}
{{ option.disabled|default(false) ? 'disabled' : null }}
>
{{ option.label }}
</option>
{% endfor %}
</select>
{% endblock %}