{%- set options = (options is defined ? options : []) %} {%- set values = (values is defined ? values : []) -%} {%- set showAllOption = (showAllOption is defined ? showAllOption : true) %} {%- if showAllOption %} {%- set allLabel = (allLabel is defined ? allLabel : "All"|t) %} {%- set allValue = (allValue is defined ? allValue : '*') %} {%- set allChecked = (values is empty or 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.request.isMobileBrowser(true)) } only %}
{%- endif %} {%- for key, option in options %} {%- set optionLabel = (option.label is defined ? option.label : option) %} {%- set optionValue = (option.value is defined ? option.value : key)~'' -%} {% if not showAllOption or optionValue != allValue %}
{% include "_includes/forms/checkbox" with { label: optionLabel, name: (name is defined ? name~'[]' : null), value: optionValue, checked: ((showAllOption and allChecked) or optionValue in values), disabled: (showAllOption and allChecked) } only %}
{% endif %} {% endfor %}