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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题