/**
  * @param FormBuilderInterface $builder
  * @param string[] $availableFormsNames
  */
 private function addAvailableFormsField(FormBuilderInterface $builder, $availableFormsNames, array $options)
 {
     $choices = [];
     foreach ($availableFormsNames as $availableFormName) {
         $choices[$availableFormName] = $this->dynamicFormsChildrenMap->getLabelByFormName($availableFormName);
     }
     $options = array_merge(['choices' => $choices, 'mapped' => false], $options['select']);
     $builder->add('_form', 'choice', $options);
 }
 /**
  * @param FormBuilderInterface $builder
  * @param string $name
  * @param string $group
  */
 private function addModelDataListener(FormBuilderInterface $builder, $name, $group)
 {
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($builder, $name, $group) {
         try {
             $data = $this->propertyAccessor->getValue($event->getData(), $name);
         } catch (\RuntimeException $exception) {
             $data = null;
         }
         if (null === $data || !is_object($data)) {
             return;
         }
         $formName = $this->dynamicFormsChildrenMap->getFormNameByGroupAndDataClass($group, get_class($data));
         $options = $event->getForm()->get($name)->get('_form')->getConfig()->getOptions();
         $event->getForm()->get($name)->add('_form', 'choice', array_merge($options, ['data' => $formName]));
         $this->addEmbeddedFormField($builder->get($name), $event->getForm()->get($name), $formName);
     });
 }