feat: prevent selection of baby rooms without regular rooms
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\Form\Model;
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Validator\Constraints as AppAssert;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
@@ -18,6 +19,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
* in participant DTOs regardless of mode, ensuring consistent data structure and
|
||||
* simplifying pricing calculations, field handlers, and template rendering.
|
||||
*/
|
||||
#[AppAssert\RoomSelection(groups: ['booking_create_step_1'])]
|
||||
class BookingDto
|
||||
{
|
||||
public const MODE_CREATE = 'create';
|
||||
@@ -175,17 +177,6 @@ class BookingDto
|
||||
return $room?->label;
|
||||
}
|
||||
|
||||
#[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();
|
||||
}
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validateBankAccount(ExecutionContextInterface $context): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user