wip: age based filtering of options
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
|
||||
/**
|
||||
@@ -14,8 +16,9 @@ use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
* for participant fields in the create flow. It extends the common field
|
||||
* state functionality provided by AbstractFieldStateProvider.
|
||||
*
|
||||
* Currently, no specific field state conditions are implemented for the
|
||||
* create workflow, but the infrastructure is ready for future additions.
|
||||
* Current field state conditions:
|
||||
* - Body dimension fields become required when rental services are selected
|
||||
* - Age-dependent service fields are hidden until birth date is provided
|
||||
*/
|
||||
class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
{
|
||||
@@ -60,6 +63,26 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
'required' => $rentalCondition,
|
||||
];
|
||||
|
||||
// Hide age-dependent fields when no date of birth is provided
|
||||
$dateOfBirthProvidedCondition = new DateOfBirthProvidedCondition();
|
||||
|
||||
// Age-dependent service fields are hidden until birth date is provided
|
||||
$this->fieldStateConditions['courses'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['additionalServices'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['rentals'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['board'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
];
|
||||
|
||||
// Example field state conditions would be registered here
|
||||
// For demonstration purposes, here are some example patterns:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user