wip: skipass-duration based rentals filtering
This commit is contained in:
@@ -16,11 +16,11 @@ use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||
* creation process. It processes the rentalInsurance field from form submissions,
|
||||
* validates the selection, and updates the participant DTO with the valid selection.
|
||||
*
|
||||
* The rental insurance field is only shown when the participant has selected
|
||||
* rental services, creating a dependency chain where rental insurance depends
|
||||
* on rental selections.
|
||||
* The rental insurance field is only shown when the participant has selected both
|
||||
* a skipass and rental services, creating a dependency chain where rental insurance
|
||||
* depends on skipass and rental selections.
|
||||
*
|
||||
* Dependencies: dateOfBirth (for age evaluation) and rentals (for field visibility)
|
||||
* Dependencies: dateOfBirth (for age evaluation), skiPass (for visibility), and rentals (for field visibility)
|
||||
*/
|
||||
class ParticipantRentalInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
{
|
||||
@@ -37,14 +37,14 @@ class ParticipantRentalInsuranceFieldHandler extends AbstractParticipantFieldHan
|
||||
/**
|
||||
* Returns the field dependencies for proper processing order.
|
||||
*
|
||||
* This handler depends on both dateOfBirth (for age evaluation) and rentals
|
||||
* (because rental insurance is only relevant when rentals are selected).
|
||||
* This handler depends on dateOfBirth (for age evaluation), skiPass (for field visibility),
|
||||
* and rentals (because rental insurance is only relevant when rentals are selected).
|
||||
*
|
||||
* @return string[] Array containing 'dateOfBirth' and 'rentals' dependencies
|
||||
* @return string[] Array containing 'dateOfBirth', 'skiPass', and 'rentals' dependencies
|
||||
*/
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return ['dateOfBirth', 'rentals'];
|
||||
return ['dateOfBirth', 'skiPass', 'rentals'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +85,12 @@ class ParticipantRentalInsuranceFieldHandler extends AbstractParticipantFieldHan
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if rental insurance should be visible based on rental selections
|
||||
// Check if rental insurance should be visible based on skipass and rental selections
|
||||
$hasSkiPass = null !== $participant->skiPass;
|
||||
$hasRentals = false === empty($participant->rentals);
|
||||
|
||||
if (false === $hasRentals) {
|
||||
// If no rentals are selected, clear rental insurance data
|
||||
if (false === $hasSkiPass || false === $hasRentals) {
|
||||
// If no skipass or no rentals are selected, clear rental insurance data
|
||||
$participant->rentalInsuranceSelected = false;
|
||||
$participant->rentalInsurance = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user