{% extends "controlpanel/base.html" %}
{% load ui %}

{% block heading %}{% if object %}Edit {{ object.name }}{% else %}New feature{% endif %}{% endblock heading %}

{% block panel %}
    <div class="card max-w-xl bg-base-100 shadow">
        <div class="card-body">
            <form method="post">
                {% csrf_token %}
                {% for error in form.non_field_errors %}
                    <div class="alert alert-error my-2">
                        <span>{{ error }}</span>
                    </div>
                {% endfor %}
                {% for field in form %}
                    <div class="form-control my-3 w-full">
                        <label class="label" for="{{ field.id_for_label }}">
                            <span class="label-text">{{ field.label }}</span>
                        </label>
                        {{ field|daisy }}
                        {% if field.help_text %}<span class="label-text-alt mt-1 text-base-content/70">{{ field.help_text }}</span>{% endif %}
                        {% for error in field.errors %}<span class="label-text-alt mt-1 text-error">{{ error }}</span>{% endfor %}
                    </div>
                {% endfor %}
                <div class="card-actions justify-end pt-2">
                    <a class="btn btn-ghost" href="{% url 'controlpanel:features' %}">Cancel</a>
                    <button class="btn btn-primary" type="submit">Save</button>
                </div>
            </form>
        </div>
    </div>
{% endblock panel %}
