FOSUserBundle managing In EasyAdminBundle(( The "User" entity must define its associated Doctrine entity class using the "class" option))Symfony
Asked Answered
S

1

9

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
    }
}
Sewer answered 1/3, 2018 at 7:33 Comment(1)
It should be a code indentation problem on your YAML file.Tidbit
J
5

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' } } }
Jackpot answered 3/3, 2018 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.