{%- set options = (options is defined ? options : []) %} {%- set values = (values is defined ? values : []) -%} {%- set showAllOption = showAllOption ?? false %} {%- if showAllOption %} {%- set allLabel = allLabel ?? "All"|t('app') %} {%- set allValue = allValue ?? '*' %} {%- set allChecked = (values == allValue) %} {%- endif %}
{%- if showAllOption %}
{% include "_includes/forms/checkbox" with { id: (id is defined ? id : null), class: 'all', label: '' ~ allLabel ~ '', name: (name is defined ? name : null), value: allValue, checked: allChecked, autofocus: (autofocus is defined and autofocus and not craft.app.request.isMobileBrowser(true)) } only %}
{%- endif %} {%- for key, option in options %} {%- if option is not iterable %} {%- set option = {label: option, value: key} %} {%- endif %} {% if not showAllOption or option.value is not defined or option.value != allValue %}
{% include "_includes/forms/checkbox" with { name: (name is defined ? name~'[]' : null), checked: ((showAllOption and allChecked) or (option.value is defined and option.value in values)), disabled: (showAllOption and allChecked) }|merge(option) only %}
{% endif %} {% endfor %}