{% load widget_tweaks %}

{% if attrs.field %}
<div class="form-control">
    {% if attrs.field.label %}
    <label class="label">
        <span class="label-text">{{ attrs.field.label }}</span>
    </label>
    {% endif %}

    {% if attrs.field.errors %}
        {% if attrs.field.field.widget.input_type == "checkbox" %}
            {% render_field attrs.field class="checkbox checkbox-error" %}
        {% elif attrs.field.field.widget.input_type == "radio" %}
            {% render_field attrs.field class="radio radio-error" %}
        {% elif attrs.field.field.widget.input_type == "select" %}
            {% render_field attrs.field class="select select-bordered select-error w-full" %}
        {% else %}
            {% render_field attrs.field class="input input-bordered input-error w-full" %}
        {% endif %}
    {% else %}
        {% if attrs.field.field.widget.input_type == "checkbox" %}
            {% render_field attrs.field class="checkbox" %}
        {% elif attrs.field.field.widget.input_type == "radio" %}
            {% render_field attrs.field class="radio" %}
        {% elif attrs.field.field.widget.input_type == "select" %}
            {% render_field attrs.field class="select select-bordered w-full" %}
        {% else %}
            {% render_field attrs.field class="input input-bordered w-full" %}
        {% endif %}
    {% endif %}

    {% if attrs.field.help_text %}
    <label class="label">
        <span class="label-text-alt text-base-content/60">{{ attrs.field.help_text }}</span>
    </label>
    {% endif %}

    {% for error in attrs.field.errors %}
    <label class="label">
        <span class="label-text-alt text-error">{{ error }}</span>
    </label>
    {% endfor %}
</div>
{% endif %}
