wip: dynamic services fields
This commit is contained in:
@@ -30,6 +30,22 @@ use App\Form\Model\BookingDtoInterface;
|
||||
*/
|
||||
interface FieldStateProviderInterface
|
||||
{
|
||||
/**
|
||||
* Determines whether a field should be included in the form at all.
|
||||
*
|
||||
* Fields with 'hidden' state conditions should not be added to the form
|
||||
* rather than being hidden with CSS. This method evaluates the hidden
|
||||
* condition independently to allow early field exclusion during form building.
|
||||
*
|
||||
* @param string $fieldName The name of the field to evaluate
|
||||
* @param BookingDtoInterface $bookingDto The current booking data for context (create or edit)
|
||||
* @param int $participantIndex The index of the participant being evaluated
|
||||
* @param array<string, mixed> $formData Current form data for condition evaluation
|
||||
*
|
||||
* @return bool True if the field should be included in the form, false if it should be excluded
|
||||
*/
|
||||
public function shouldIncludeField(string $fieldName, BookingDtoInterface $bookingDto, int $participantIndex, array $formData = []): bool;
|
||||
|
||||
/**
|
||||
* Calculates the dynamic state for a specified field.
|
||||
*
|
||||
@@ -38,11 +54,14 @@ interface FieldStateProviderInterface
|
||||
* The returned array contains Symfony form field attributes that control
|
||||
* field behavior and appearance.
|
||||
*
|
||||
* Note: This method no longer handles 'hidden' state as fields should be
|
||||
* excluded from the form entirely using shouldIncludeField() rather than
|
||||
* hidden with CSS.
|
||||
*
|
||||
* State attributes may include:
|
||||
* - 'attr' => ['readonly' => true] - Make field readonly
|
||||
* - 'disabled' => true - Disable field interaction
|
||||
* - 'required' => false - Override field requirement
|
||||
* - 'attr' => ['style' => 'display: none'] - Hide field
|
||||
* - 'attr' => ['class' => 'conditional-field'] - Add CSS classes
|
||||
*
|
||||
* @param string $fieldName The name of the field to evaluate
|
||||
|
||||
Reference in New Issue
Block a user