<ips:template parameters="$name, $value, $required, $options, $multiple=FALSE, $class='', $disabled=FALSE, $toggles=array(), $id=NULL, $unlimited=NULL, $unlimitedLang='all', $unlimitedToggles=array(), $toggleOn=TRUE, $descriptions=array()" />
{{if $multiple}}
	<input type="hidden" name="{$name}[__EMPTY]" value="__EMPTY">
{{endif}}
{{if $unlimited !== NULL}}
	<div data-control="granularCheckboxset">
		<div data-role="checkboxsetUnlimited" class="{{if !\is_array( $value )}}ipsJS_show{{else}}ipsHide{{endif}}">
			<input
				type='checkbox'
				name="{expression="trim( $name, '[]' )"}_unlimited"
				value='{$unlimited}'
				id="{expression="trim( $id ?: $name, '[]' )"}_unlimited"
				{{if $unlimited === $value}}checked aria-checked='true'{{else}}aria-checked='false'{{endif}}
				{{if $disabled}}disabled aria-disabled='true'{{endif}}
				data-ipsToggle
				data-role="checkboxsetUnlimitedToggle"
			>
			&nbsp;
			{lang="or"}
			&nbsp;
			<a class="ipsCursor_pointer" data-action="checkboxsetCustomize">{lang="customize"}</a>
		</div>
{{endif}}
		<div data-role="checkboxsetGranular" class="{{if $unlimited !== NULL and !\is_array( $value )}}ipsJS_hide{{endif}}">
			<ul class="ipsField_fieldList">
			{{foreach $options as $k => $v}}
				<li>
					<span class='ipsCustomInput'>
						<input type="checkbox" {{if $class}}class="{$class}"{{endif}} name="{$name}[{$k}]" value="1" {{if ( $unlimited !== NULL AND $unlimited === $value ) or ( \is_array( $value ) AND \in_array( $k, $value ) )}}checked{{endif}} {{if $disabled === TRUE or ( \is_array( $disabled ) and \in_array( $k, $disabled ) )}}disabled{{endif}} {{if isset( $toggles[ $k ] ) and !empty( $toggles[ $k ] )}}data-control="toggle" {{if $toggleOn === FALSE}}data-togglesOff{{else}}data-togglesOn{{endif}}="{expression="implode( ',', $toggles[ $k ] )"}"{{endif}} id="elCheckbox_{$name}_{$k}">
						<span></span>
					</span>
					<div class='ipsField_fieldList_content'>
						<label for='elCheckbox_{$name}_{$k}' id='elField_{$name}_label'>{$v|raw}</label>
						{{if isset( $descriptions[ $k ] )}}
							<br>
							<span class='ipsFieldRow_desc'>
								{$descriptions[ $k ]|raw}
							</span>
						{{endif}}
					</div>
				</li>
			{{endforeach}}
			</ul>
			{{if $unlimited !== NULL}}
				<div class="ipsSpacer_top ipsSpacer_half">
					{lang="or"}
					&nbsp;
					<a class="ipsCursor_pointer" data-action="checkboxsetAll">{lang="all"}</a> / <a class="ipsCursor_pointer" data-action="checkboxsetNone">{lang="none"}</a>
				</div>
		</div>
			{{endif}}
	</div>