Symfony 5 - how to merge two field in one with collectionType

32 views Asked by At

i have a collectionType (echeance) with a entry_type a other formType with 2 fields

Entity field

    public function setEcheancesReglement(array $echeancesReglement): self
        {
            //$this->echeancesReglement = $echeancesReglement;
            return $this;
        }

Collection field :

    ->add('echeancesReglement', CollectionType::class, [
                'required' => false,
                'label' => 'Échéances',
                'attr' => ['class' => 'symfony-collection'],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
                'prototype' => true,
                'entry_type' => FacturePaiementEcheancesType::class,
                'entry_options' => ['label' => false],
            ])

FacturePaiementEcheancesType

     $builder
         ->add('echeancesDate', DatePickerType::class, [
             'mapped' => false,
             'required' => false,
             'label' => 'Échéances',
             'attr' => ['class' => 'form-vertical echeancesDate'],
         ])
         ->add('echeancesMontant', TextType::class, [
             'required' => false,
             'mapped' => false,
             'label' => 'Montant',
             'attr' => ['class' => 'form-vertical echeancesMontant'],
         ])
     ;

i wish to get values of "date" and "montant" for create array for set in my entity (setEcheancesReglement) Maybe an Event Listener on $form->handleRequest($request) in the controller, but i doesn't work (I deleted this event to start again)

Thank you and sorry for the bad translation

0

There are 0 answers