"App\Entity\Cat" 实体的配置不可用(此实体用作 "cat" 自动完成字段的目标)
The configuration of the "App\Entity\Cat" entity is not available (this entity is used as the target of the "cat" autocomplete field)
我正在尝试使用 Symfony 4 配置 EasyAdmin 后端。
但是,当我尝试编辑 post 时,我得到:
The configuration of the "App\Entity\Cat" entity is not available (this entity is used as the target of the "cat" autocomplete field).
我试过另一个实体(用户),它运行良好。
你们知道这个配置是什么吗and/or如何让它可用?谢谢。
这是实际配置:
formats:
blabla
entities:
User:
class: App\Entity\User
list:
fields: ['username', 'roles', 'email', 'registration_datetime', 'status']
Post:
class: App\Entity\Post
list:
fields: blabla
edit:
fields:
- {type: 'group', columns: 9}
- {property: 'title', type_options: { block_name: 'custom_title' }}
- {property: 'body', type: 'fos_ckeditor'}
- {type: 'group', columns: 3}
- {property: 'cat', type: 'easyadmin_autocomplete', type_options: {class: 'App\Entity\Cat'}}
- {property: 'subcat', type: 'easyadmin_autocomplete', type_options: {class: 'App\Entity\Subcat'}}
- 'tile'
- 'place'
site_name: 'ShadowTech'
user:
name_property_path: 'username'
下面是 Cat
实体:
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CatRepository")
*/
class Cat
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Post", mappedBy="cat")
*/
private $posts;
/**
* @ORM\Column(type="string", length=100)
*/
private $readable_name;
public function __construct()
{
$this->posts = 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 __toString()
{
return $this->getReadableName();
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setCat($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
// set the owning side to null (unless already changed)
if ($post->getCat() === $this) {
$post->setCat(null);
}
}
return $this;
}
public function getReadableName(): ?string
{
return $this->readable_name;
}
public function setReadableName(string $readable_name): self
{
$this->readable_name = $readable_name;
return $this;
}
}
因此,如评论中所述 - 您只需将此实体的配置添加到 easy_admin.yaml
。
像那样:
#config/packages/easy_admin.yaml
easy_admin:
entities:
Cat:
class: App\Entity\Cat
我正在尝试使用 Symfony 4 配置 EasyAdmin 后端。
但是,当我尝试编辑 post 时,我得到:
The configuration of the "App\Entity\Cat" entity is not available (this entity is used as the target of the "cat" autocomplete field).
我试过另一个实体(用户),它运行良好。
你们知道这个配置是什么吗and/or如何让它可用?谢谢。
这是实际配置:
formats:
blabla
entities:
User:
class: App\Entity\User
list:
fields: ['username', 'roles', 'email', 'registration_datetime', 'status']
Post:
class: App\Entity\Post
list:
fields: blabla
edit:
fields:
- {type: 'group', columns: 9}
- {property: 'title', type_options: { block_name: 'custom_title' }}
- {property: 'body', type: 'fos_ckeditor'}
- {type: 'group', columns: 3}
- {property: 'cat', type: 'easyadmin_autocomplete', type_options: {class: 'App\Entity\Cat'}}
- {property: 'subcat', type: 'easyadmin_autocomplete', type_options: {class: 'App\Entity\Subcat'}}
- 'tile'
- 'place'
site_name: 'ShadowTech'
user:
name_property_path: 'username'
下面是 Cat
实体:
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CatRepository")
*/
class Cat
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Post", mappedBy="cat")
*/
private $posts;
/**
* @ORM\Column(type="string", length=100)
*/
private $readable_name;
public function __construct()
{
$this->posts = 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 __toString()
{
return $this->getReadableName();
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setCat($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
// set the owning side to null (unless already changed)
if ($post->getCat() === $this) {
$post->setCat(null);
}
}
return $this;
}
public function getReadableName(): ?string
{
return $this->readable_name;
}
public function setReadableName(string $readable_name): self
{
$this->readable_name = $readable_name;
return $this;
}
}
因此,如评论中所述 - 您只需将此实体的配置添加到 easy_admin.yaml
。
像那样:
#config/packages/easy_admin.yaml
easy_admin:
entities:
Cat:
class: App\Entity\Cat