feat: body dimensions mandatory with selected rentals, updated help text

feat: body dimensions mandatory with selected rentals
This commit is contained in:
Björn Fromme
2026-03-16 12:02:28 +01:00
parent 957e20d763
commit 667324df69
4 changed files with 100 additions and 10 deletions
+4 -7
View File
@@ -50,17 +50,14 @@ class BodyDimensionsType extends AbstractType
{
$resolver->setDefaults([
'data_class' => ParticipantDto::class,
'height_required' => false,
'weight_required' => false,
'shoeSize_required' => false,
'height_required' => true,
'weight_required' => true,
'shoeSize_required' => true,
'height_choices' => [],
'weight_choices' => [],
'shoe_size_min' => 36,
'shoe_size_max' => 48,
'help' => 'Du kannst die Daten auch später nachreichen',
'help_attr' => [
'class' => 'lg:col-span-3 text-sm -mt-2 px-2',
],
'help' => 'Verleih kann bis 4 Tage vor Anreise in MyE&P nachgebucht werden, sollten dir (noch) nicht alle Angaben vorliegen',
]);
$resolver->setAllowedTypes('height_required', 'bool');
@@ -22,6 +22,7 @@ class ParticipantValidator extends ConstraintValidator
$participant = $value;
$this->assertPickupSelected($participant);
$this->assertBodyDimensionsWhenRentalsSelected($participant);
}
public function assertPickupSelected(ParticipantDto $participant): void
@@ -40,4 +41,34 @@ class ParticipantValidator extends ConstraintValidator
;
}
}
public function assertBodyDimensionsWhenRentalsSelected(ParticipantDto $participant): void
{
// Check if any rental services are selected
if (true === empty($participant->rentals)) {
return;
}
// Require body dimensions when rentals are selected
if (null === $participant->height || '' === $participant->height) {
$this->context->buildViolation('Bitte auswählen')
->atPath('height')
->addViolation()
;
}
if (null === $participant->weight || '' === $participant->weight) {
$this->context->buildViolation('Bitte auswählen')
->atPath('weight')
->addViolation()
;
}
if (null === $participant->shoeSize || '' === $participant->shoeSize) {
$this->context->buildViolation('Bitte auswählen')
->atPath('shoeSize')
->addViolation()
;
}
}
}