<div id="{{ form.hx_target }}">
    <form enctype="multipart/form-data" 
    {% if form.hx_post %}hx-post="{{ form.hx_post }}"{% endif %}
    {% if form.hx_target %}hx-target="#{{ form.hx_target }}"{% endif %}
    {% if form.hx_trigger %}hx-trigger="{{ form.hx_trigger }}"{% endif %}
    {% if form.hx_swap %}hx-swap="{{ form.hx_swap }}"{% endif %}
    >
    {% csrf_token %}
        <div>{% if success and form.disable_on_success %}{{ form.as_bs5_disabled }}{% else %}{{ form.as_bs5 }}{% endif %}</div>
        {% if form.align %}
        <div class="d-flex justify-content-{{ form.align }}">
            <button type="submit" class="btn btn-primary" {% if success and form.disable_on_success %}disabled{% endif %}>{{ form.submit_button_text }}</button>
        </div>
        {% else %}
        <button type="submit" class="btn btn-primary" {% if success and form.disable_on_success %}disabled{% endif %}>{{ form.submit_button_text }}</button>
        {% endif %}
    </form>
    {% if form.align %}
    <div class="my-2 d-flex justify-content-{{ form.align }}">
        {% if success and form.success_message %}
            {% if form.use_alert_for_success_message %}
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <span class="my-2 fw-bold">{{ form.success_message }}</span>
                {% if results %}<span>{{ results }}</span>{% endif %}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            {% else %}
            <div class="my-2 fw-bold text-success">{{ form.success_message }}</div>
            {% endif %}
        {% endif %}
    </div>
    {% else %}
        {% if success and form.success_message %}
            {% if form.use_alert_for_success_message %}
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <span class="my-2 fw-bold">{{ form.success_message }}</span>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            {% else %}
            <div class="my-2 fw-bold text-success">{{ form.success_message }}</div>
            {% endif %}
        {% endif %}
        {% if results %}
        <div hx-swap-oob="true" id="{{ form.hx_target }}-results" class="me-3 text-primary my-2 d-flex justify-content-{{ form.align }}">{{ results|safe }}</div>
        {% endif %}
    {% endif %}
</div>

