make familial situations and professionnal situations configurable

This commit is contained in:
2019-05-09 14:01:53 +02:00
parent 04506781cd
commit d0dc6b3378
11 changed files with 219 additions and 66 deletions

View File

@@ -44,9 +44,7 @@ class FamilyMemberType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$professionnalSituations = \array_flip(AbstractDiagnosticNIAssignment::PROFESSIONNAL_SITUATIONS);
$professionnalSituations["Scolarité"] = 'scolarite';
$builder
->add('lastname', TextType::class, [
'label' => 'Last name'
@@ -58,23 +56,35 @@ class FamilyMemberType extends AbstractType
->add('birthdate', ChillDateType::class, [
'required' => false
])
->add('professionnalSituation', ChoiceType::class, [
'required' => false,
'choices' => $professionnalSituations
])
->add('link', ChoiceType::class, [
'choices' => $this->getLinks(),
'choices' => $this->buildChoices($this->configRepository->getLinksLabels()),
'placeholder' => 'Choose a link',
'label' => 'Relationship'
])
->add('maritalStatus', Select2MaritalStatusType::class, [
'required' => false
])
->add('familialSituation', ChoiceType::class, [
'label' => 'Familial situation',
'required' => false,
'choices' => \array_flip(AbstractFamilyMember::FAMILIAL_SITUATION)
]);
;
if ($this->configRepository->hasProfessionalSituation()) {
$builder
->add('professionnalSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getProfessionalSituationsLabels()
)
]);
}
if ($this->configRepository->hasProfessionalSituation()) {
$builder
->add('familialSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getFamilialSituationsLabels()
)
]);
}
if ($options['show_start_date']) {
$builder
@@ -108,17 +118,18 @@ class FamilyMemberType extends AbstractType
;
}
private function getLinks()
private function buildChoices($els)
{
$links = $this->configRepository
->getLinksLabels();
$choices = [];
// rewrite labels to filter in language
foreach ($links as $key => $labels) {
$links[$key] = $this->translatableStringHelper->localize($labels);
foreach ($els as $key => $labels) {
$choices[$this->translatableStringHelper->localize($labels)] = $key;
}
return \array_flip($links);
return $choices;
}
/**