configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; } /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $professionnalSituations = \array_flip(AbstractDiagnosticNIAssignment::PROFESSIONNAL_SITUATIONS); $professionnalSituations["Scolarité"] = 'scolarite'; $builder ->add('lastname', TextType::class, [ 'label' => 'Last name' ]) ->add('firstname', TextType::class, [ 'label' => 'First name' ]) ->add('gender', GenderType::class) ->add('birthdate', ChillDateType::class, [ 'required' => false ]) ->add('professionnalSituation', ChoiceType::class, [ 'required' => false, 'choices' => $professionnalSituations ]) ->add('link', ChoiceType::class, [ 'choices' => $this->getLinks(), '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 ($options['show_start_date']) { $builder ->add('startDate', ChillDateType::class, [ 'label' => 'Arrival date in the family' ]); } if ($options['show_end_date']) { $builder ->add('endDate', ChillDateType::class, [ 'required' => false, 'label' => 'Departure date of the family' ]); } }/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => FamilyMember::class, 'show_start_date' => true, 'show_end_date' => true, )); $resolver ->setAllowedTypes('show_start_date', 'boolean') ->setAllowedTypes('show_end_date', 'boolean') ; } private function getLinks() { $links = $this->configRepository ->getLinksLabels(); // rewrite labels to filter in language foreach ($links as $key => $labels) { $links[$key] = $this->translatableStringHelper->localize($labels); } return \array_flip($links); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'chill_amli_familymembersbundle_familymember'; } }