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' %}
{% load static %}
{% block title %}Verleih Anfrage{% endblock %}
{% block content %}
<!-- Main Content -->
<main class="container mx-auto w-full px-4 my-8 flex-1">
<h1 class="page-title">Verleih Anfrage</h1>
<form action="" enctype="multipart/form-data" method="POST" class="multiSectionForm max-w-2xl">
{% csrf_token %}
{% include "baseform/non_field_errors.html" %}
<section>
<h2>Persönliche Daten</h2>
<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="sm:col-span-3">
{% include "baseform/text.html" with field=form.firstname %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.surname %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.organization %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.matriculation_number %}
</div>
<div class="sm:col-span-3">
{% include "baseform/email.html" with field=form.email %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.phone %}
</div>
</div>
</section>
<section>
<h2>Verleihgegenstände</h2>
<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">
{% if form.rentalitems.errors %}
<div class="col-span-full alert alert-danger">
<div class="alert-body">{{ form.rentalitems.errors }}</div>
</div>
{% endif %}
<div id="{{ form.rentalitems.auto_id }}" class="col-span-full">
{% for elem in form.rentalitems %}
<div class="col-span-2 mb-2">
<label for="{{ elem.id_for_label }}">
<input
type="checkbox"
id="{{ elem.id_for_label }}"
name="{{ form.rentalitems.html_name }}"
value="{{ elem.data.value }}"
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
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"
>{{ elem.choice_label }}</a>
</label>
{% for item in rentalitems_addinfo %}
{% if item.name == elem.choice_label and item.induction %}
<p class="text-xs text-gray-700 dark:text-gray-200">Einschulung erforderlich!</p>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="sm:col-span-3">
{% include "baseform/date.html" with field=form.date_start %}
</div>
<div class="sm:col-span-3">
{% include "baseform/date.html" with field=form.date_end %}
</div>
<div class="col-span-full">
{% include "baseform/textarea.html" with field=form.reason %}
</div>
</div>
</section>
<section>
<h2>Zusätzliche Informationen</h2>
<small>Hier kannst du zusätzliche Informationen, Anliegen und Sonstiges angeben.</small>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="col-span-full">
{% include "baseform/textarea.html" with field=form.comment %}
</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">
{% include "baseform/checkbox.html" with field=form.conformation %}
</div>
<a href="{% static 'rental/verleihregeln.pdf' %}" target='_blank' class="inline-flex items-center px-2 py-1">
<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>
<span class="ml-2 sm:ml-1 text-gray-700 dark:text-gray-200">Verleihregeln</span>
</a>
</div>
</section>
<section class="flex justify-end">
<button type="submit" class="btn btn-primary w-full sm:w-auto" value="Einreichen">Anfrage abschicken</button>
</section>
</form>
</main>
{% endblock content %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Verleih Anfrage{% endblock %}
{% block content %}
<!-- Main Content -->
<main class="container mx-auto w-full px-4 my-8 flex-1">
<h1 class="page-title">Verleih Anfrage</h1>
<form action="" enctype="multipart/form-data" method="POST" class="multiSectionForm max-w-2xl">
{% csrf_token %}
{% include "baseform/non_field_errors.html" %}
<section>
<h2>Persönliche Daten</h2>
<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="sm:col-span-3">
{% include "baseform/text.html" with field=form.firstname %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.surname %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.organization %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.matriculation_number %}
</div>
<div class="sm:col-span-3">
{% include "baseform/email.html" with field=form.email %}
</div>
<div class="sm:col-span-3">
{% include "baseform/text.html" with field=form.phone %}
</div>
</div>
</section>
<section>
<h2>Verleihgegenstände</h2>
<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">
{% if form.rentalitems.errors %}
<div class="col-span-full alert alert-danger">
<div class="alert-body">{{ form.rentalitems.errors }}</div>
</div>
{% endif %}
<div id="{{ form.rentalitems.auto_id }}" class="col-span-full">
{% for elem in form.rentalitems %}
<div class="col-span-2 mb-2">
<label for="{{ elem.data.value }}">
<input
type="checkbox"
id="{{ elem.data.value }}"
name="{{ form.rentalitems.html_name }}"
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"
>
<a
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"
title="Details zu {{ elem.choice_label }}"
aria-label="Details zu {{ elem.choice_label }}"
>{{ elem.choice_label }}</a>
</label>
{% for item in rentalitems_addinfo %}
{% if item.name == elem.choice_label and item.induction %}
<p class="text-xs text-gray-700 dark:text-gray-200">Einschulung erforderlich!</p>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="sm:col-span-3">
{% include "baseform/date.html" with field=form.date_start %}
</div>
<div class="sm:col-span-3">
{% include "baseform/date.html" with field=form.date_end %}
</div>
<div class="col-span-full">
{% include "baseform/textarea.html" with field=form.reason %}
</div>
</div>
</section>
<section>
<h2>Zusätzliche Informationen</h2>
<small>Hier kannst du zusätzliche Informationen, Anliegen und Sonstiges angeben.</small>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="col-span-full">
{% include "baseform/textarea.html" with field=form.comment %}
</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">
{% include "baseform/checkbox.html" with field=form.conformation %}
</div>
<a href="{% static 'rental/verleihregeln.pdf' %}" target='_blank' class="inline-flex items-center px-2 py-1">
<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>
<span class="ml-2 sm:ml-1 text-gray-700 dark:text-gray-200">Verleihregeln</span>
</a>
</div>
</section>
<section class="flex justify-end">
<button type="submit" class="btn btn-primary w-full sm:w-auto" value="Einreichen">Anfrage abschicken</button>
</section>
</form>
</main>
{% endblock content %}