DoctrineEnumBundle: Could not load type when using EasyAdminBundle

After register type as

types:
     UserRoleType: AF\Bundle\UserBundle\DBAL\Types\UserRoleType

I get exception: Could not load type “UserRoleType”

why?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 33 (15 by maintainers)

Most upvoted comments

@allfreelancers Here is a quick and dirty solution for you. As EasyAdmin cannot guess enum form types right now, you should set them manually. Here is how your config can look like.

easy_admin:
    entities:
        Example:
            class: AppBundle\Entity\Example
            list:
                fields:
                    - 'id'
                    - { property: 'role', type: 'text' }
            form:
                fields:
                    - { property: 'role', type: 'choice', type_options: { choices: {'Freelancer':'freelancer', 'Employer':'employer', 'Both':'both' } }  }

I understand that it is too much manual work for each entity which uses enums. But right now it can help you to solve your problem and move on until I find a way how to integrate it into EasyAdminBundle. I took a look on those configurators, I have some idea how to tweak it, but right now don’t have enough time. So will continue fixing this issue few days later.

P.S. I also updated my bitbucket example where this config works

@allfreelancers it’s hard to read the code you paste in your comments. Luckily there’s a simple solution for that. You just need to add some ``` like this:

``` <-- add this before the code
YOUR CODE HERE...
``` <-- add this after the code

And to enable highlighting, use this:

```yaml
YOUR YAML CODE HERE...
```

```php
YOUR PHP CODE HERE...
```

Thanks!

@javiereguiluz thank you alot, I wose edit my posts