{% if field.is_hidden %}
    {{ field }}
{% else %}
    <div id="{{ field.auto_id }}-group" class="form-group field-{{ field_class }} widget-{{ widget_class }}{% if is_checkbox %} form-check{% endif %}{% if field.field.required %} required{% endif %}{% if extra_classes %} {{ extra_classes }}{% endif %}">
        {% if show_label and not is_checkbox %}
        <label for="{{ field.auto_id }}" id="{{ field.auto_id }}-label">{{ field.label }}</label>
        {% endif %}
        <div class="controls clearfix">
            {% if use_fieldset %}
                <div id='{{ field.auto_id }}'>
                    {% for choice in field %}
                        <div class="form-check">
                            {{ choice.tag }}
                            <label class="form-check-label" id="{{ choice.id_for_label }}-label" for="{{ choice.id_for_label }}">{{ choice.choice_label }}</label>
    
                            {% if forloop.last %}
                                {% if field.help_text %}
                                    <small id="{{ field.auto_id }}-help" class="form-text text-muted">{{ field.help_text|safe }}</small>
                                {% endif %}
                                {% if field.errors %}
                                    <ul id="{{ field.auto_id }}-errors" class="errorlist invalid-feedback">
                                        {% for error in field.errors %}
                                            <li>{{ error|escape }}</li>
                                        {% endfor %}
                                    </ul>
                                {% endif %}
                            {% endif %}
                        </div>
                    {% endfor %}
                </div>
            {% else %}
                {% if is_checkbox %}
                    {{ field }}
                    <label class="form-check-label" id="{{ field.auto_id }}-label" for="{{ field.auto_id }}">{{ field.label }}</label>
                {% else %}
                    {{ field }}
                {% endif %}
                
                {% if field.help_text %}
                    <small id="{{ field.auto_id }}-help" class="form-text text-muted">{{ field.help_text|safe }}</small>
                {% endif %}
                {% if field.errors %}
                    <ul id="{{ field.auto_id }}-errors" class="errorlist invalid-feedback">
                        {% for error in field.errors %}
                            <li>{{ error|escape }}</li>
                        {% endfor %}
                    </ul>
                {% endif %}
            {% endif %}
        </div>
    </div>
{% endif %}
