Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonata Exception get too many admin registered

I get the message:

Unable to found a valid admin for the class: Aman\VarshneyBundle\Entity\ArticleTable, get too many admin registered: sonata.admin.appsreview,sonata.admin.review,sonata.admin.article

I am not able to figure out this issue.

like image 883
Aman Varshney Avatar asked Jan 16 '14 06:01

Aman Varshney


2 Answers

you have to specify "admin_code" option in your field definition

in your admin class while building your form

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper->add('user', 'entity', array(), array(
        'admin_code' => 'your.user.admin.service'

    ));
}

It only happens when you have multiple admin classes for the same entity.

like image 74
bratek Avatar answered Dec 24 '22 12:12

bratek


I will put code with the use for the 'configureListFields' method, if it's usefull for someone.

protected function configureListFields(ListMapper $listMapper)
{
$listMapper
    ->add('filename', null, array('admin_code' => 'your.file.admin.service', 'label' => 'File Name'))
    ->add('parent', 'sonata_type_list', array('admin_code' => 'your.file.admin.service', 'label' => 'Parent File'))
    ->add('_action', 'actions', array(
        'label' => 'Actions',
        'actions' => array(
            'download' => array(
                'template' => 'FileAdminBundle:File:list__action_download.html.twig'
            )
        )
    ));
}

As we see, if we have multiple fields, we must put the 'admin_code' in all of them, excepts the actions (if we have it).

Hope it helps.

like image 23
Juan Carlos Avatar answered Dec 24 '22 11:12

Juan Carlos