feat: validate room selection
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user