fix: wrong binding for checked box

This commit is contained in:
2025-10-30 10:32:46 +01:00
parent 370577493a
commit 4d35e498c5

View File

@@ -1,121 +1,123 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Verleih Anfrage{% endblock %} {% block title %}Verleih Anfrage{% endblock %}
{% block content %} {% block content %}
<!-- Main Content --> <!-- Main Content -->
<main class="container mx-auto w-full px-4 my-8 flex-1"> <main class="container mx-auto w-full px-4 my-8 flex-1">
<h1 class="page-title">Verleih Anfrage</h1> <h1 class="page-title">Verleih Anfrage</h1>
<form action="" enctype="multipart/form-data" method="POST" class="multiSectionForm max-w-2xl"> <form action="" enctype="multipart/form-data" method="POST" class="multiSectionForm max-w-2xl">
{% csrf_token %} {% csrf_token %}
{% include "baseform/non_field_errors.html" %} {% include "baseform/non_field_errors.html" %}
<section> <section>
<h2>Persönliche Daten</h2> <h2>Persönliche Daten</h2>
<small>Bitte gib deine persönlichen Daten ein.</small> <small>Bitte gib deine persönlichen Daten ein.</small>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6"> <div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.firstname %} {% include "baseform/text.html" with field=form.firstname %}
</div> </div>
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.surname %} {% include "baseform/text.html" with field=form.surname %}
</div> </div>
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.organization %} {% include "baseform/text.html" with field=form.organization %}
</div> </div>
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.matriculation_number %} {% include "baseform/text.html" with field=form.matriculation_number %}
</div> </div>
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/email.html" with field=form.email %} {% include "baseform/email.html" with field=form.email %}
</div> </div>
<div class="sm:col-span-3"> <div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.phone %} {% include "baseform/text.html" with field=form.phone %}
</div> </div>
</div> </div>
</section> </section>
<section> <section>
<h2>Verleihgegenstände</h2> <h2>Verleihgegenstände</h2>
<small>Wähl deine gewünschten Verleihgegenstände aus.</small> <small>Wähl deine gewünschten Verleihgegenstände aus.</small>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6 pb-6 col-span-full"> <div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6 pb-6 col-span-full">
{% if form.rentalitems.errors %} {% if form.rentalitems.errors %}
<div class="col-span-full alert alert-danger"> <div class="col-span-full alert alert-danger">
<div class="alert-body">{{ form.rentalitems.errors }}</div> <div class="alert-body">{{ form.rentalitems.errors }}</div>
</div> </div>
{% endif %} {% endif %}
<div id="{{ form.rentalitems.auto_id }}" class="col-span-full"> <div id="{{ form.rentalitems.auto_id }}" class="col-span-full">
{% for elem in form.rentalitems %} {% for elem in form.rentalitems %}
<div class="col-span-2 mb-2"> <div class="col-span-2 mb-2">
<label for="{{ elem.data.value }}">
<label for="{{ elem.id_for_label }}"> <input
<input type="checkbox"
type="checkbox" id="{{ elem.data.value }}"
id="{{ elem.id_for_label }}" name="{{ form.rentalitems.html_name }}"
name="{{ form.rentalitems.html_name }}" value="{{ elem.data.value }}"
value="{{ elem.data.value }}" {% if elem.data.selected %}checked{% endif %}
class="rounded border-gray-300 dark:border-none text-proprietary shadow-sm focus:border-blue-300 focus:ring focus:ring-offset-0 focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" class="rounded border-gray-300 dark:border-none text-proprietary shadow-sm focus:border-blue-300 focus:ring focus:ring-offset-0 focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50"
> >
<a <a
href="{% url 'rental:rentalitem_detail' elem.data.value %}" href="{% url 'rental:rentalitem_detail' elem.data.value %}"
class="text-gray-700 dark:text-gray-200 underline hover:text-blue-700 dark:hover:text-blue-300" class="text-gray-700 dark:text-gray-200 underline hover:text-blue-700 dark:hover:text-blue-300"
>{{ elem.choice_label }}</a> title="Details zu {{ elem.choice_label }}"
</label> aria-label="Details zu {{ elem.choice_label }}"
>{{ elem.choice_label }}</a>
{% for item in rentalitems_addinfo %} </label>
{% if item.name == elem.choice_label and item.induction %}
<p class="text-xs text-gray-700 dark:text-gray-200">Einschulung erforderlich!</p> {% for item in rentalitems_addinfo %}
{% endif %} {% if item.name == elem.choice_label and item.induction %}
{% endfor %} <p class="text-xs text-gray-700 dark:text-gray-200">Einschulung erforderlich!</p>
</div> {% endif %}
{% endfor %} {% endfor %}
</div> </div>
</div> {% endfor %}
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6"> </div>
<div class="sm:col-span-3"> </div>
{% include "baseform/date.html" with field=form.date_start %} <div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
</div> <div class="sm:col-span-3">
<div class="sm:col-span-3"> {% include "baseform/date.html" with field=form.date_start %}
{% include "baseform/date.html" with field=form.date_end %} </div>
</div> <div class="sm:col-span-3">
<div class="col-span-full"> {% include "baseform/date.html" with field=form.date_end %}
{% include "baseform/textarea.html" with field=form.reason %} </div>
</div> <div class="col-span-full">
</div> {% include "baseform/textarea.html" with field=form.reason %}
</section> </div>
</div>
<section> </section>
<h2>Zusätzliche Informationen</h2>
<small>Hier kannst du zusätzliche Informationen, Anliegen und Sonstiges angeben.</small> <section>
<h2>Zusätzliche Informationen</h2>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6"> <small>Hier kannst du zusätzliche Informationen, Anliegen und Sonstiges angeben.</small>
<div class="col-span-full">
{% include "baseform/textarea.html" with field=form.comment %} <div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
</div> <div class="col-span-full">
</div> {% include "baseform/textarea.html" with field=form.comment %}
</section> </div>
</div>
<section> </section>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="col-span-full text-gray-700 dark:text-gray-200"> <section>
{% include "baseform/checkbox.html" with field=form.conformation %} <div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
</div> <div class="col-span-full text-gray-700 dark:text-gray-200">
<a href="{% static 'rental/verleihregeln.pdf' %}" target='_blank' class="inline-flex items-center px-2 py-1"> {% include "baseform/checkbox.html" with field=form.conformation %}
<i class="fa-solid fa-file-pdf fa-fw text-red-800 dark:text-red-500 md:text-inherit group-hover:text-red-800 dark:group-hover:text-red-500"></i> </div>
<span class="ml-2 sm:ml-1 text-gray-700 dark:text-gray-200">Verleihregeln</span> <a href="{% static 'rental/verleihregeln.pdf' %}" target='_blank' class="inline-flex items-center px-2 py-1">
</a> <i class="fa-solid fa-file-pdf fa-fw text-red-800 dark:text-red-500 md:text-inherit group-hover:text-red-800 dark:group-hover:text-red-500"></i>
</div> <span class="ml-2 sm:ml-1 text-gray-700 dark:text-gray-200">Verleihregeln</span>
</section> </a>
</div>
<section class="flex justify-end"> </section>
<button type="submit" class="btn btn-primary w-full sm:w-auto" value="Einreichen">Anfrage abschicken</button>
</section> <section class="flex justify-end">
</form> <button type="submit" class="btn btn-primary w-full sm:w-auto" value="Einreichen">Anfrage abschicken</button>
</main> </section>
{% endblock content %} </form>
</main>
{% endblock content %}