all-in-one-event-calendar/public/admin/twig/form-elements/select.twig
2017-03-16 16:59:53 +01:00

37 lines
977 B
Twig

{% macro select( id, name='', attributes = [], options = [] ) %}
{% if name == '' %}
{% set name = id %}
{% endif %}
<select
name="{{ name }}"
id="{{ id }}"
class="ai1ec-form-control {{ attributes.class }}"
{% for attribute, value in attributes %}
{% if attribute != 'class' %}
{{ attribute }}="{{ value }}"
{% endif %}
{% endfor %}
>
{% for key, option in options %}
{% if key is string %}
<optgroup label="{{ key }}">
{% for opt in option %}
<option
value="{{ opt.value }}"
{% for attribute, value in opt.args %}
{{ attribute }}="{{ value }}"
{% endfor %}
>{{ opt.text }}</option>
{% endfor %}
</optgroup>
{% else %}
<option
value="{{ option.value | dropdown_filter }}"
{% for attribute, value in option.args %}
{{ attribute }}="{{ value }}"
{% endfor %}
>{{ option.text | dropdown_filter }}</option>
{% endif %}
{% endfor %}
</select>
{% endmacro %}