3

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 phone in Sonata\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?

Ionut
  • 113
  • 1
  • 10
  • 1
    This is now solved. It was a stupid mistake on my part. I did not put the correct resource import in the config file. – Ionut Mar 30 '13 at 21:02
  • Can you post the solution and mark it as accepted so others that have the same problem can see the solution please ! – Etienne Noël Apr 10 '14 at 02:48

1 Answers1

3

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.

Ionut
  • 113
  • 1
  • 10