{% extends 'forms/' ~ layout|default('field') ~ '.html.twig' %}

{% block input %}
    {% for key, text in field.options %}
        {% set checked = (field.use == 'keys' ? value[key] : key in value) %}
        {% set childName = name|fieldName ~ '[' ~ (field.use == 'keys' ? key : '') ~ ']' %}
        {% set key = (field.use == 'keys' ? '1' : key) %}
        <span class="checkboxes">
            <input type="checkbox"
                   id="{{ childName }}"
                   value="{{ key }}"
                   name="{{ (scope ~ childName)|fieldName }}"
                   {% if checked %}checked="checked"{% endif %}
                    {% if field.validate.required %}required="required"{% endif %}
                    >
            <label for="{{ childName }}">{{ text }}</label>
        </span>
    {% endfor %}
{% endblock %}
