首页 > 解决方案 > 如何在 symfony 3 中将集合添加到集合表单中

问题描述

我在 symfony 3 中有 3 种表单类型

PanneauType,它是所有下一个集合的父级

            ->add('faces', CollectionType::class, array(
                'entry_type' => FacePanneauType::class,
                'entry_options' => array('label' => false),
                'allow_add' => true,
                'allow_delete' => true,
            ))

面型

->add('agendas', CollectionType::class, array(
                'entry_type' => AgendaType::class,
                'entry_options' => array('label' => false),
                'allow_add' => true,
                'allow_delete' => true,
                'attr' =>['class'=>'agendas']
            ))

议程类型

->add('debut', null, ['attr'=>['class'=>'form-control']])
 ->add('fin', null, ['attr'=>['class'=>'form-control']])

如何在树枝中生成我的表单添加和删除议程类型?

标签: symfonycollectionssymfony-3.3

解决方案


这就是你要找的:

https://symfony.com/doc/current/form/form_collections.html

为此,您将需要一些 Javascript :)


推荐阅读