doutang3760 2018-03-01 07:33
浏览 36
已采纳

FOSUserBundle管理EasyAdminBundle((“用户”实体必须使用“class”选项定义其关联的Doctrine实体类))Symfony

I am using Symfony 3.4 with FOSUserBundle~2.0 and EasyAdminBundle^1.17.everything works fine.i can login to system and create user ((ofcourse with commend line)) i using this toutaril but when i want to managing in EasyAdminBundle.i have this error

The "User" entity must define its associated Doctrine entity class using the "class" option.

this is my 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' } } }

.
.
.

This is user entity

<?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
    }
}
  • 写回答

1条回答 默认 最新

  • doukenqiong0588 2018-03-03 09:48
    关注

    All of your options for User entity should be nested under User

        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' } } }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃