fix: correctly distinguish between first participant and applicant
This commit is contained in:
1 parent
15dbd72f93
commit
ce828a6ef5
5 files changed
+96
-97
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* Condition that checks if the participant is the first participant (index 0).
|
||||
*
|
||||
* This is used to apply field state logic specifically for the first participant
|
||||
* in the booking, such as requiring address fields or showing DOB-dependent fields.
|
||||
*
|
||||
* Note: This checks if the participant is at index 0, NOT if they are the "applicant"
|
||||
* in the BPN sense (the logged-in user). For agency-initiated bookings, the first
|
||||
* participant may be different from the applicant/logged-in user.
|
||||
*/
|
||||
class FirstParticipantCondition implements FieldConditionInterface
|
||||
{
|
||||
/**
|
||||
* Evaluates if the participant is the first participant.
|
||||
*
|
||||
* @param BookingDto $bookingDto The current booking data
|
||||
* @param int $participantIndex The index of the participant being evaluated
|
||||
* @param array<string, mixed> $formData Current form data (unused)
|
||||
*
|
||||
* @return bool True if the participant is the first participant (index 0)
|
||||
*/
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
return 0 === $participantIndex;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Checks if the participant is the first participant (index 0)';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user