From 3d71dcfc14a1a67811e9fd171ef918d172c859b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?=
Date: Wed, 4 Mar 2026 16:24:50 +0100
Subject: [PATCH] feat: ensure teamer accepts terms when confirming driver's
license
---
src/Form/DriverLicenseDeclarationType.php | 20 ++++++++-----
src/Model/DriverLicenseDeclarationDto.php | 30 ++++++++++++++++++-
.../teamer/check/driver_license.html.twig | 16 ++++++----
3 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/src/Form/DriverLicenseDeclarationType.php b/src/Form/DriverLicenseDeclarationType.php
index a1e66ef..90c8b3f 100644
--- a/src/Form/DriverLicenseDeclarationType.php
+++ b/src/Form/DriverLicenseDeclarationType.php
@@ -6,6 +6,7 @@ use App\Model\DriverLicenseDeclarationDto;
use App\Model\UploadSessionDto;
use App\Service\Upload\UploadHandler;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
@@ -16,13 +17,18 @@ class DriverLicenseDeclarationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
- $builder->add('hasDriverLicense', ChoiceType::class, [
- 'label' => 'Besitzt du einen gültigen Führerschein?',
- 'choices' => [
- 'Ja' => true,
- 'Nein' => false,
- ],
- ]);
+ $builder
+ ->add('hasDriverLicense', ChoiceType::class, [
+ 'label' => 'Besitzt du einen gültigen Führerschein?',
+ 'choices' => [
+ 'Ja' => true,
+ 'Nein' => false,
+ ],
+ ])
+ ->add('confirmTermsOfUse', CheckboxType::class, [
+ 'label' => 'Ich bestätige, die KfZ-Nutzungsbedingungen gelesen zu haben und stimme ihnen zu.',
+ ])
+ ;
}
public function buildView(FormView $view, FormInterface $form, array $options): void
diff --git a/src/Model/DriverLicenseDeclarationDto.php b/src/Model/DriverLicenseDeclarationDto.php
index b020da4..e1608d7 100644
--- a/src/Model/DriverLicenseDeclarationDto.php
+++ b/src/Model/DriverLicenseDeclarationDto.php
@@ -3,11 +3,26 @@
namespace App\Model;
use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Component\Validator\Context\ExecutionContextInterface;
class DriverLicenseDeclarationDto
{
#[Assert\NotNull(message: 'Bitte gib an, ob du einen Führerschein hast.')]
- private ?bool $hasDriverLicense = null;
+ private ?bool $hasDriverLicense;
+
+ private ?bool $confirmTermsOfUse = false;
+
+ #[Assert\Callback]
+ public function validateTermsOfUse(ExecutionContextInterface $executionContext): void
+ {
+ if (true === $this->hasDriverLicense() && true !== $this->getConfirmTermsOfUse()) {
+ $executionContext
+ ->buildViolation('Bitte bestätige die KfZ-Nutzungsbedingungen.')
+ ->atPath('confirmTermsOfUse')
+ ->addViolation()
+ ;
+ }
+ }
public function __construct(?bool $hasDriverLicense = null)
{
@@ -25,4 +40,17 @@ class DriverLicenseDeclarationDto
return $this;
}
+
+ public function getConfirmTermsOfUse(): ?bool
+ {
+ return $this->confirmTermsOfUse;
+ }
+
+ public function setConfirmTermsOfUse(?bool $confirmTermsOfUse): static
+ {
+ $this->confirmTermsOfUse = $confirmTermsOfUse;
+
+ return $this;
+ }
+
}
diff --git a/templates/teamer/check/driver_license.html.twig b/templates/teamer/check/driver_license.html.twig
index 372a3d9..eda869b 100644
--- a/templates/teamer/check/driver_license.html.twig
+++ b/templates/teamer/check/driver_license.html.twig
@@ -15,12 +15,6 @@
Führerscheins hoch.
- {% if not form.vars.valid %}
-
- {% include '_partials/_form_errors.html.twig' with { 'form': form } %}
-
- {% endif %}
-
{% if teamer.driverLicenseStatus == constant('App\\Entity\\Teamer::DRIVER_LICENSE_STATUS_DENIED') %}
{% embed '_partials/_alert.html.twig' with { 'type': 'warning' } %}
{% block message %}
@@ -33,6 +27,14 @@
{% endembed %}
{% endif %}
+ {% if not form.vars.valid %}
+ {% embed '_partials/_alert.html.twig' with { 'type': 'warning' } %}
+ {% block message %}
+ {% include '_partials/_form_errors.html.twig' with { 'form': form } %}
+ {% endblock %}
+ {% endembed %}
+ {% endif %}
+
{{ form_row(form.hasDriverLicense) }}
@@ -55,6 +57,8 @@
'accepted_files': 'image/jpg,image/jpeg,image/png,application/pdf',
} %}
+
+ {{ form_row(form.confirmTermsOfUse) }}