ChillPersonBundle: Add numberOfDependents and numberOfDependentsWithDisabilities

This commit is contained in:
Christophe Siraut
2024-12-20 11:28:36 +01:00
parent 5f31473c90
commit fbdc0d32f0
15 changed files with 220 additions and 6 deletions

View File

@@ -19,10 +19,19 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class HouseholdCompositionType extends AbstractType
{
public function __construct(private readonly HouseholdCompositionTypeRepository $householdCompositionTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
private array $fields_visibility;
public function __construct(
private readonly HouseholdCompositionTypeRepository $householdCompositionTypeRepository,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
protected ParameterBagInterface $parameterBag,
) {
$this->fields_visibility = $parameterBag->get('chill_person.person_fields');
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -42,7 +51,19 @@ class HouseholdCompositionType extends AbstractType
->add('numberOfChildren', IntegerType::class, [
'required' => true,
'label' => 'household_composition.numberOfChildren',
])
]);
if ('visible' == $this->fields_visibility['number_of_dependents']) {
$builder
->add('numberOfDependents', IntegerType::class, [
'required' => true,
'label' => 'household_composition.numberOfDependents',
])
->add('numberOfDependentsWithDisabilities', IntegerType::class, [
'required' => true,
'label' => 'household_composition.numberOfDependentsWithDisabilities',
]);
}
$builder
->add('comment', CommentType::class, [
'required' => false,
]);