我正在使用Symfony 3.4和FOSUserBundle~2.0以及EasyAdminBundle ^ 1.17。一切正常。我可以登录系统并创建用户((当然有推荐行))我使用这个toutaril 但是当我想在EasyAdminBundle.i中管理时出现此错误
The "User" entity must define its associated Doctrine entity class using the "class" option.
这是我的config.yml
..
.
.
entities:
User:
label: 'user'
list:
actions:
- {name: 'delete', label: 'del' }
- {name: 'edit' , lable: 'edite'}
title: 'user'
fields:
- username
- email
- enabled
- lastLogin
class: AppBundle\Entity\User
form:
fields:
- username
- email
- enabled
- lastLogin
# if administrators are allowed to edit users' passwords and roles, add this:
- { property: 'plainPassword', type: 'text', type_options: { required: false } }
- { property: 'roles', type: 'choice', type_options: { multiple: true, choices: { 'ROLE_USER': 'ROLE_USER', 'ROLE_ADMIN': 'ROLE_ADMIN' } } }
.
.
.
这是用户实体
<?php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
答案 0 :(得分:5)
用户实体的所有选项都应嵌套在用户
下 entities:
User:
label: 'user'
list:
actions:
- {name: 'delete', label: 'del' }
- {name: 'edit' , lable: 'edite'}
title: 'user'
fields:
- username
- email
- enabled
- lastLogin
class: AppBundle\Entity\User
form:
fields:
- username
- email
- enabled
- lastLogin
# if administrators are allowed to edit users' passwords and roles, add this:
- { property: 'plainPassword', type: 'text', type_options: { required: false } }
- { property: 'roles', type: 'choice', type_options: { multiple: true, choices: { 'ROLE_USER': 'ROLE_USER', 'ROLE_ADMIN': 'ROLE_ADMIN' } } }