feat: validate room selection

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 9d2474c1e3
commit 82b47e314b
2 changed files with 13 additions and 0 deletions
+12
View File
@@ -4,6 +4,7 @@ namespace App\Form\Model;
use App\BusProNet\Model\Travel; use App\BusProNet\Model\Travel;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
class BookingCreateDto implements BookingDtoInterface class BookingCreateDto implements BookingDtoInterface
{ {
@@ -49,4 +50,15 @@ class BookingCreateDto implements BookingDtoInterface
{ {
return $this->participants[$index] ?? null; return $this->participants[$index] ?? null;
} }
#[Assert\Callback(callback: 'validateRoomSelection', groups: ['booking_create_step_1'])]
public function validateRoomSelection(ExecutionContextInterface $context): void
{
$selectedRooms = $this->getSelectedRooms();
if (0 === count($selectedRooms)) {
$context->buildViolation('Bitte mindestens ein Zimmer/Bett auswählen')
->addViolation();
}
}
} }
@@ -9,6 +9,7 @@
Unterkunft Unterkunft
</h2> </h2>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_errors(form) }}
{% if groupedRooms.by_room is not empty %} {% if groupedRooms.by_room is not empty %}
<h3> <h3>
Zimmer Zimmer