Search code examples
symfonysymfony4easyadmin

Easyadmin bundle of Symfony


I am creating backend using Symfony. I want to create submenu. I am writing following code in easy_admin file inside config/packages:

easy_admin:
    design:
        menu:
            - label: 'Products'
              icon: 'shopping-basket'
              children:
                  - { entity: 'Product', icon: 'th-list', label: 'List Products' }
                  - { entity: 'Product', label: 'Add Product' }
                  - { label: 'Additional Items' }
                  - { entity: 'User', label: 'Users' }

I have created entities of Product and User located in src/Entity

But I am getting error:

The "Product" entity included in the "menu" option is not managed by EasyAdmin. The menu can only include any of these entities: .

What I am doing wrong? Thank you in advance!


Solution

  • To solve your problem you need at first read carefully the documentation on easyadmin. Then you find there that you need to add your entities to easyadmin config file, smth like this:

    # config/packages/easy_admin.yaml
    easy_admin:
    # ...
        entities:
            - App\Entity\Product
            - App\Entity\User
    

    or

    # config/packages/easy_admin.yaml
    easy_admin:
    # ...
        entities:
            Product:
                class: App\Entity\Product
            User:
                class: App\Entity\User