views/macros/select field: add support for custom value/display options

This commit is contained in:
Alice Gaudon 2020-07-27 10:55:41 +02:00
parent e046a77aa8
commit c32048e047
1 changed files with 2 additions and 1 deletions

View File

@ -65,7 +65,8 @@
{% elseif type == 'select' %}
<select name="{{ name }}" id="field-{{ name }}" {{ validation_attributes|safe }}>
{% for option in extraData %}
<option value="{{ option }}" {{ 'selected' if value == option }}>{{ option }}</option>
<option value="{% if option.display === undefined or option.value !== undefined %}{{ option.value | default(option) }}{% endif %}"
{{ 'selected' if value == (option.value | default(option)) }}>{{ option.display | default(option) }}</option>
{% endfor %}
</select>
<i data-feather="chevron-down"></i>