SonataAdminBundle: Unable to use the sonata_type_admin field - Field not linked to an admin

I have an entity “Author” and “Image” with a simple OneToOne relation. I tried to embed an Admin class in my Author admin class for the “image” field which is linked to the Image entity.

The mapping betweens the two classes is correct.

I created an Admin class for each entity :

The current field image is not linked to an admin. Please create one for the target entity : ``

The admin services are registred in the admin.yml (I used http://sonata-project.org/bundles/admin/master/doc/reference/form_types.html#sonata-type-admin) :

services:
    sonata.admin.author:
        class: Project\BackendBundle\Admin\AuthorAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "Author" }
        arguments:
            - ~
            - Project\BackendBundle\Entity\Author
            - ~

    sonata.admin.image:
        class: Project\BackendBundle\Admin\ImageAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "Image" }
        arguments:
            - ~
            - Project\BackendBundle\Entity\Image
            - 'SonataAdminBundle:CRUD'

I followed all the documentation but now I don’t see the problem. I even try to pass the FieldDescription option “admin_code” :

$formMapper
    ->add('name', 'text', array('label' => 'Author name'))
    ->add(
        'image',
        'sonata_type_admin',
        array(),
        array('admin_code' => 'sonata.admin.image')
    )
;

I use the lastest version of sonata admin bundle sonata-project/admin-bundle.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 40 (39 by maintainers)

Most upvoted comments

That would have save my day indeed, I’ll look into it.

Realy weird : when I dump $metadata from a contact create form this is not my Contact entity but my User entity metadata… which is not related to Contact entity at all

Thanks for your help anyway @greg0ire