wip: field states and dependencies

This commit is contained in:
Björn Fromme committed 2026-03-16 11:59:09 +01:00
1 parent cd7a724e62
commit d0d6844fbd
10 files changed
+1302 -22

No files matched your search

@@ -7,11 +7,12 @@ namespace App\Form\ParticipantFieldHandler;
use App\Form\Model\BookingCreateDto;
/**
* Interface for handling dynamic participant form field processing.
* Interface for handling dynamic participant form field processing and state modification.
*
* Participant field handlers are responsible for processing submitted form data
* for booking participants and updating the BookingCreateDto accordingly.
* They support dependency management to ensure fields are processed in the correct order.
* for booking participants and updating the BookingCreateDto accordingly. They also
* support field state modification based on processed data and business logic.
* Handlers support dependency management to ensure fields are processed in the correct order.
*/
interface ParticipantFieldHandlerInterface
{
@@ -40,4 +41,30 @@ interface ParticipantFieldHandlerInterface
* Determines if this handler should process the field based on submitted participant data.
*/
public function shouldProcess(array $submittedData, int $participantIndex): bool;
/**
* Returns field state modifications that should be applied after processing.
*
* This method allows handlers to dynamically modify the state of form fields
* based on the processed data. It's called after processField() and can be used
* to enable/disable/hide fields based on the handler's processing results.
*
* @param array<string, mixed> $submittedData The submitted participant form data
* @param BookingCreateDto $bookingDto The booking DTO (potentially modified by processing)
* @param int $participantIndex The participant index being processed
*
* @return array<string, array<string, mixed>> Field state modifications indexed by field name
*/
public function getFieldStateModifications(array $submittedData, BookingCreateDto $bookingDto, int $participantIndex): array;
/**
* Returns field names whose state is affected by this handler's processing.
*
* This method declares which form fields have their state modified by this handler.
* It's used for dependency tracking and determining when field states need to be
* recalculated during form processing.
*
* @return string[] Array of field names that this handler may modify the state of
*/
public function getAffectedFieldNames(): array;
}