How to pass options to CustomType in `collection` field Symfony 2.1?

前端 未结 2 1945
说谎
说谎 2021-02-05 05:03

I have SuperType Form for Entity Super.

In this form I have a collection field of ChildType Form types for Entity

2条回答
  •  长发绾君心
    2021-02-05 05:40

    You can pass an array of options to your childType as follows:

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('childrens', 'collection', array(
                'entry_type' => new ChildType(),  
                'entry_options'  => array(
                    'my_custom_option' => true,
                ),
        // ...
    
    }
    

提交回复
热议问题