{% extends 'base.html' %}
{% load crispy_forms_filters %}
{% load i18n %}
{% load custom_filters %}

{% block title %}{% trans "Car Finance Details" %}{% endblock %}

{% block content %}
<div class="container p-4">
    <p class="mb-4">{% trans "Finance Details for" %}
        {{ car.id_car_make.get_local_name }} - {{ car.id_car_model.get_local_name }}
    </p>

    <!-- Display Validation Errors -->
    {% if form.errors %}
        <div class="alert alert-danger">
            <ul>
                {% for field in form %}
                    {% for error in field.errors %}
                        <li>{{ field.label }}: {{ error }}</li>
                    {% endfor %}
                {% endfor %}
                {% for error in form.non_field_errors %}
                    <li>{{ error }}</li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}
<form method="post" class="needs-validation" novalidate>
    <div class="row g-1">
        <div class="col-lg-4 col-xl-12">
            
                {% csrf_token %}
                
                      {{ form|crispy }}
        </div>
    </div>
    <div class="row g-1">
                <div class="btn-group">
                    <button type="submit" class="btn btn-sm btn-success me-1">{% trans "Save" %}</button>
                    <a href="{{request.META.HTTP_REFERER}}" class="btn btn-sm btn-danger">{% trans "Cancel" %}</a>
                </div>
           
        </div>
 </form>
</div>

<!-- JavaScript Section -->

{% endblock %}