wip: modernized edit flow

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 0d073a36a3
commit 28831a3b06
75 changed files with 1662 additions and 747 deletions
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
#[\Attribute]
class ApplicantAddress extends Constraint
{
public function getTargets(): string
{
return self::CLASS_CONSTRAINT;
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace App\Validator\Constraints;
use App\Form\Model\ParticipantDto;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class ApplicantAddressValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint): void
{
/** @var ParticipantDto $participant */
$participant = $value;
// Only validate for the first participant (applicant in create mode)
if (false === $participant->isApplicant()) {
return;
}
// Ensure address object exists
if (null === $participant->address) {
return;
}
// Validate required address fields
if (null === $participant->address->street || '' === trim($participant->address->street)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.street')
->addViolation()
;
}
if (null === $participant->address->postCode || '' === trim($participant->address->postCode)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.postCode')
->addViolation()
;
}
if (null === $participant->address->city || '' === trim($participant->address->city)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.city')
->addViolation()
;
}
if (null === $participant->address->country || '' === trim($participant->address->country)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.country')
->addViolation()
;
}
// Mobile/phone is mandatory for applicant in create mode
if (null === $participant->mobile || '' === trim($participant->mobile)) {
$this->context->buildViolation('Bitte angeben')
->atPath('mobile')
->addViolation()
;
}
}
}
@@ -16,7 +16,6 @@ class ParticipantValidator extends ConstraintValidator
$this->assertBodyMeasurementsValid($participant);
$this->assertTransportationSelected($participant);
$this->assertPickupSelected($participant);
$this->assertApplicantAddressValid($participant);
}
public function assertBodyMeasurementsValid(ParticipantDto $participant): void
@@ -68,49 +67,4 @@ class ParticipantValidator extends ConstraintValidator
;
}
}
public function assertApplicantAddressValid(ParticipantDto $participant): void
{
// Address is only mandatory for the applicant (first participant)
if (false === $participant->isApplicant()) {
return;
}
// Check each required address field for applicant
if (null === $participant->address->street || '' === trim($participant->address->street)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.street')
->addViolation()
;
}
if (null === $participant->address->postCode || '' === trim($participant->address->postCode)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.postCode')
->addViolation()
;
}
if (null === $participant->address->city || '' === trim($participant->address->city)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.city')
->addViolation()
;
}
if (null === $participant->address->country || '' === trim($participant->address->country)) {
$this->context->buildViolation('Bitte angeben')
->atPath('address.country')
->addViolation()
;
}
// Mobile/phone is mandatory for applicant
if (null === $participant->mobile || '' === trim($participant->mobile)) {
$this->context->buildViolation('Bitte angeben')
->atPath('mobile')
->addViolation()
;
}
}
}