Symfony EasyAdmin 3.x ManyToMany添加时出现错误:Doctrine 类型的 ....字段为"4",EasyAdmin 尚不支持该字段



我正在尝试使用 easyAdmin 3.x 在两个类之间建立简单的 ManyToMany 关系,当我尝试显示实体 CRUD 时,我经常出现此错误:

">

salles"字段的学说类型是"4",EasyAdmin尚不支持该类型。

两个实体都存在字符串__to函数

public function __toString()
{
return $this->name;
}

我的 CrudController:

namespace AppControllerAdmin;
use AppEntityBatiment;
use EasyCorpBundleEasyAdminBundleControllerAbstractCrudController;

class BatimentCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Batiment::class;
}

public function configureFields(string $pageName): iterable
{
return [
'name',
'salles'
];
}
}

easyadmin 3.x不管理多对多关系吗?

是否有一种特殊的方法来管理和显示这些关系?

我发现了这个捆绑包,感谢您的帮助!

在 EasyAdmin 3.x 中,为所有关联映射添加了新的专用 fied 类型。

请使用类似以下内容:

namespace AppControllerAdmin;

use AppEntityBatiment;
use EasyCorpBundleEasyAdminBundleControllerAbstractCrudController;
use EasyCorpBundleEasyAdminBundleFieldAssociationField;
use EasyCorpBundleEasyAdminBundleFieldField;


class BatimentCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Batiment::class;
}
public function configureFields(string $pageName): iterable
{
return [
Field::new('id')->hideOnForm(),
Field::new('name'),
Field::new('Letter'),
ImageField::new('image'),
AssociationField::new('products')
];
}
}

这是我的 Batiment 实体类的定义

<?php
namespace AppEntity;
use AppRepositoryBatimentRepository;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity(repositoryClass=BatimentRepository::class)
*/
class Batiment
{
/**
* @ORMId()
* @ORMGeneratedValue()
* @ORMColumn(type="integer")
*/
private $id;
/**
* @ORMColumn(type="string", length=255)
*/
private $name;
/**
* @ORMColumn(type="string", length=255, nullable=true)
*/
private $Letter;
/**
* @ORMColumn(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORMOneToMany(targetEntity=Salle::class, mappedBy="batiment")
*/
private $salles;
public function __construct()
{
$this->salles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getLetter(): ?string
{
return $this->Letter;
}
public function setLetter(?string $Letter): self
{
$this->Letter = $Letter;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
/**
* @return Collection|Salle[]
*/
public function getSalles(): Collection
{
return $this->salles;
}
public function addSalle(Salle $salle): self
{
if (!$this->salles->contains($salle)) {
$this->salles[] = $salle;
$salle->setBatiment($this);
}
return $this;
}
public function removeSalle(Salle $salle): self
{
if ($this->salles->contains($salle)) {
$this->salles->removeElement($salle);
// set the owning side to null (unless already changed)
if ($salle->getBatiment() === $this) {
$salle->setBatiment(null);
}
}
return $this;
}
public function __toString()
{
return $this->name;
}
}

关于简单的管理配置(yaml(,我没有特定的配置。

我在easyadmin 3.x的文档中没有找到关于这个问题的观点。

使用 easyadmindocumention 2.x,我尝试将这些参数放在 config/packages/easyadmin.yaml 中。

没有成功!

easy_admin:
entities:
#        # List the entity class name you want to manage
- AppEntityBatiment
- AppEntityDispositionSalle
- AppEntitySalle

最新更新