{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{% trans_default_domain 'EasyAdminBundle' %}

{% if ea.crud.currentAction == 'detail' or not field.customOptions.get('renderAsSwitch') %}
    {% set badge_is_hidden = ea.crud.currentAction == 'index'
        and (
            (field.value == true and field.customOptions.get('hideValueWhenTrue') == true)
            or
            (field.value == false and field.customOptions.get('hideValueWhenFalse') == true)
        ) %}

    {% if not badge_is_hidden %}
        <span class="badge {{ field.value == true ? 'badge-boolean-true' : 'badge-boolean-false' }}">
            {{ (field.value == true ? 'label.true' : 'label.false')|trans }}
        </span>
    {% endif %}
{% else %}
    <div class="form-check form-switch">
        <input type="checkbox" class="form-check-input" id="{{ field.uniqueId }}" {{ field.value == true ? 'checked' }}
            data-toggle-url="{{ field.customOptions.get('toggleUrl') }}"
            {{ field.formTypeOption('disabled') == true ? 'disabled' }} autocomplete="off">
        <label class="form-check-label" for="{{ field.uniqueId }}"></label>
    </div>
{% endif %}
