I have extended SonataUserBundle using SonataEasyExtendsBundle and removed some of the fields. The database table is created correctly. The problem is when trying to add an user in the Admin interface (using SonataAdminBundle). I am getting:
Please define a type for field
phoneinSonata\UserBundle\Admin\Entity\UserAdmin
This leads me to the conclusion that the Admin Bundle is not picking up my custom class and it uses the default one.
My config.yml:
sonata_user:
security_acl: false
manager_type: orm
class:
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
My Application\Sonata\UserBundle\Resources\services.xml
<service id="sonata.user.admin.user" class="Application\Sonata\UserBundle\Admin\Entity\UserAdmin">
<tag name="sonata.admin" manager_type="orm" group="%sonata.user.admin.groupname%" label="users" label_catalogue="SonataUserBundle" label_translator_strategy="sonata.admin.label.strategy.underscore" />
<argument />
<argument>Application\Sonata\UserBundle\Entity\User</argument>
<argument>SonataAdminBundle:CRUD</argument>
<call method="setUserManager">
<argument type="service" id="fos_user.user_manager" />
</call>
<call method="setTranslationDomain">
<argument>%sonata.user.admin.user.translation_domain%</argument>
</call>
</service>
The question is how do I register my user class with Sonata Admin and, eventually un-register the default class?
I've solved this by adding the proper import into the /app/config/config.yml file.
#/app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: '@ApplicationSonataUserBundle/Resources/config/services.xml' }
The new class was defined in the services file posted above and it was not picked up automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With