问题描述
请问如何在sonata admin中创建多级子级? 我有一个 Section 类,它与同一个类有 childSection 关系。我怎么能有这样的情况,即部分可以有 childSection,而 childSection 可以有另一个 childSection 等...
这是我的实体类:
class Section
{
/**
* @ORM\ManyToOne(targetEntity=Section::class,inversedBy="childrenSection")
*/
private $parentSection;
/**
* @ORM\OneToMany(targetEntity=Section::class,mappedBy="parentSection")
*/
private $childrenSection;
}
Services.yaml
admin.section:
class: App\Admin\SectionAdmin
arguments: [~,App\Entity\Section,~]
tags:
- { name: sonata.admin,manager_type: orm,label: Section }
calls:
- [addChild,['@admin.section','parentSection']]
public: true
管理类:
SectionAdmin.php
final class SectionAdmin extends AbstractAdmin
{
protected function configureRoutes(RouteCollection $collection)
{
$collection
->add('parentSection',$this->getRouterIdParameter() . '/section/list');
}
protected function configureListFields(ListMapper $listMapper): void
{
$listMapper
->add('id')
->add('name')
->add('_action',null,[
'actions' => [
'edit' => [],'delete' => [],'parentSection' => ['template' => 'BUTTON LIST SECTION FILE'],],]);
}
}
我面临以下错误:
检测到服务“admin.section”的循环引用,路径: “admin.section -> admin.section”。
有什么方法可以在不限制奏鸣曲管理中的子级深度的情况下创建子级吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)