{% comment %}
Переиспользуемый компонент для отображения полей формы
Использование:
    {% include 'mainapp/components/_form_field.html' with field=form.field_name %}
    {% include 'mainapp/components/_form_field.html' with field=form.field_name label_class="custom-label" %}
{% endcomment %}

<div class="mb-3">
    <label for="{{ field.id_for_label }}" class="form-label {% if label_class %}{{ label_class }}{% endif %}">
        {{ field.label }}
        {% if field.field.required %}<span class="text-danger">*</span>{% endif %}
    </label>
    
    {% if field.field.widget.input_type == 'checkbox' %}
        <div class="form-check">
            {{ field }}
        </div>
    {% else %}
        {{ field }}
    {% endif %}
    
    {% if field.errors %}
        <div class="invalid-feedback d-block">
            {% for error in field.errors %}
                {{ error }}
            {% endfor %}
        </div>
    {% endif %}
    
    {% if field.help_text %}
        <small class="form-text text-muted">{{ field.help_text }}</small>
    {% endif %}
</div>
