Symfony 2.8/3.0-将数组从collectionType传递到另一个formType


Symfony 2.8/3.0 - Pass array to another formType from a collectionType

我可以在v2.8之前实现这一点,但由于symfony现在使用完全限定的类名name,我不确定如何继续。我可以毫无问题地将数组(用于填充选择字段)传递给表单,但如果通过collectionType添加了另一个formType,如何传递数组?

BTW-数组是从自定义注释中收集的数据,而不是实体这是我的代码:

PageType.php

    <?php
    namespace Prototype'PageBundle'Form;
    use Symfony'Component'Form'AbstractType;
    use Symfony'Component'Form'FormBuilderInterface;
    use Symfony'Component'OptionsResolver'OptionsResolver;
    const ActiveComponentsType = 'Prototype'PageBundle'Form'ActiveComponentsType';
    const collectionType = 'Symfony'Component'Form'Extension'Core'Type'CollectionType';
    class PageType extends AbstractType
    {
        private $cmsComponentArray;
        public function __construct($cmsComponentArray = null)
        {
           $this->cmsComponentArray = $cmsComponentArray;
        }
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $cmsComponentArray = $options['cmsComponentArray'];
            $componentChoices = array();
            foreach($cmsComponentArray as $cmsComponent){
                $componentChoices[$cmsComponent['name']] = $cmsComponent['route'];
            }
            //correct values are shown here
            //print_r($componentChoices);
            $builder
                ->add('title')
                ->add('parent')
                ->add('template')
                ->add('active')
                ->add('content')
                ->add('components', collectionType, array(
                    'entry_type'   => ActiveComponentsType, // i want to pass $cmsComponentArray to ActiveComponentsType 
                    'allow_add' => true,
                    'allow_delete' => true
                ))
            ;
        }
        /**
         * @param OptionsResolver $resolver
         */
        public function configureOptions(OptionsResolver $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'Prototype'PageBundle'Entity'Page',
                'cmsComponentArray' => null
            ));
        }
    }

ActiveComponentsType嵌入表单确实有效,只是我不确定如何将$componentChoices数组传递给它

有什么想法吗?

集合类型定义entry_options选项,该选项用于配置传递给嵌入表单类型的选项。