我的目标是创建一本书的章节,在每一章中,我可以拥有任意数量的章节作为子章节。我有一个实体,它是每一章的一本书的一章,我可以添加一个子章(实际上是另一章(但 id parent 不为空))
class Chapter
{
/**
* One champ has One parent champ.
* @ORM\ManyToOne(targetEntity="Chapter", inversedBy="children")
* @ORM\JoinColumn(name="id_parent", referencedColumnName="id")
*/
public $parent;
/**
* One champ has Many champs.
* @ORM\OneToMany(targetEntity="Chapter", mappedBy="parent",cascade={"persist"}))
* @ORM\OrderBy({"ordre" = "ASC"})
*/
public $children;
我想在每一章中使用 symfony 添加/删除/修改,所以我有以下表单类型
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('libelleLong', textType::class, ['label'=> 'titre']);
$builder->add('children', CollectionType::class,[
'entry_type' => ChapterType::class,
'entry_options' => ['label' => false,'block_name' => 'childrenList'],
'block_name' => 'childrenList',
'label'=> false,
'allow_add'=>true,
'allow_delete'=> true,
'prototype'=> true,
'by_reference' => false,
]
);
}
但是这条线'prototype'=> true把一切都放下了......
[2020 年 5 月 19 日 20:57:08 UTC] PHP 致命错误:供应商\symfony\symfony\src\Symfony\Component\Debug\Exception\OutOfMemoryException 中允许的 134217728 字节的内存大小已耗尽(试图分配 32768 字节)。第 1 行的 php
我怎样才能让孩子们使用原型?
aluckdog