after commit 7d7dd0683b245e6e3c214b9fbd4224cb86249ba8
I have problem with multiple types of admin classes for one Entity
Unable to found a valid admin for the class: Topes\WebsiteBundle\Entity\Category, get too many admin registered: sonata.page.admin.category,sonata.page.admin.categorychild,sonata.page.admin.categorygrandchild,sonata.page.admin.categoryeda,sonata.page.admin.gud.foodcategory

Is there any solution for it?
The exception has been added to catch this kind of situation where the AdminPool select the last admin defined for the Class. This might lead to error because the target Admin can be wrong.
I need the stack trace to see to source of the error, In case this occurs in a list, you can do:
->addIdentifier('product', null, array(
'admin_code' => 'sonata.product.admin.product'
));
See https://github.com/sonata-project/ecommerce/blob/develop/src/Sonata/ProductBundle/Admin/ProductCategoryAdmin.php#L56-L58 for more information.
Closing for now, unless you provide me the stack trace.
thank you for solution
cheers!
@rande , sorry but now i have the same problem with sonata_type_model in configureFormFields
->add('category', 'sonata_type_model', array(
// 'query' => $query_categories,
'admin_code' => 'sonata.page.admin.category',
'label' => '袣邪褌械谐芯褉懈褟',
'required' => true) )
Ok the admin_code is not supported every where yet ... Can you gist the stack trace ? so I can add this asap !
https://gist.github.com/markyboryslav/8398617
sorry, but I am newby
I think you need third file
try
->add('category', 'sonata_type_model', array(
// 'query' => $query_categories,
'label' => '袣邪褌械谐芯褉懈褟',
'required' => true),
array('admin_code' => 'sonata.page.admin.category',) )
great, thank you!
Same error with SonataMediaBundle + SonantaAdminBundle :
An exception has been thrown during the rendering of a template ("Unable to found a valid admin for the class: ADA\NewsBundle\Entity\News, get too many admin registered: sonata.admin.adminada.news,sonata.admin.translator.news") in SonataMediaBundle:MediaAdmin:list_image.html.twig at line 15.
In the admin Class:
class NewsAdmin extends Admin
{
[...]
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add(
'image',
'string',
array('template' => 'SonataMediaBundle:MediaAdmin:list_image.html.twig'),
array('admin_code' => 'sonata.admin.adminada.news')
)
->addIdentifier('title')
[...]
@acrozes in listMapper must be
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add(
'image',
'string',
array('template' => 'SonataMediaBundle:MediaAdmin:list_image.html.twig',
'admin_code' => 'sonata.admin.adminada.news')
)
Just a head up to anyone else experiencing this issue as it tripped me up for a bit, each field needs admin code. Bit messy but only way I could resolve this.
'admin_code' resolve the problem for me EXCEPT for child creat page .
With logistique admin page and logistique2 Admin page for logistique entity:
/app_dev.php/admin/logistique/32/edit : OK
/app_dev.php/admin/logistique/32/ligne/create : Unable to find a valid admin for the class
MagasinBundle\Entity\Logistique.
Need to do 2 child admin too ?
Stack Trace
[1] RuntimeException: Unable to find a valid admin for the class: MagasinBundle\Entity\Logistique, there are too many registered: magasin.admin.logistique, magasin.admin.logistique2 at n/a in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\Pool.php line 195 at Sonata\AdminBundle\Admin\Pool->getAdminByClass('MagasinBundle\Entity\Logistique') in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\AbstractAdmin.php line 1313 at Sonata\AdminBundle\Admin\AbstractAdmin->attachAdminClass(object(FieldDescription)) in C:\xampp\htdocs\stocks\vendor\sonata-project\doctrine-orm-admin-bundle\Builder\FormContractor.php line 75 at Sonata\DoctrineORMAdminBundle\Builder\FormContractor->fixFieldDescription(object(LigneAdmin), object(FieldDescription), array('type' => 'Symfony\Bridge\Doctrine\Form\Type\EntityType')) in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Form\FormMapper.php line 111 at Sonata\AdminBundle\Form\FormMapper->add('logistique', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array('class' => 'MagasinBundle:Ligne', 'label' => 'Requ锚te Logistique', 'required' => true, 'disabled' => true)) in C:\xampp\htdocs\stocks\src\MagasinBundle\Admin\LigneAdmin.php line 130 at MagasinBundle\Admin\LigneAdmin->configureFormFields(object(FormMapper)) in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\AbstractAdmin.php line 1292 at Sonata\AdminBundle\Admin\AbstractAdmin->defineFormBuilder(object(FormBuilder)) in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\AbstractAdmin.php line 1277 at Sonata\AdminBundle\Admin\AbstractAdmin->getFormBuilder() in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\AbstractAdmin.php line 3236 at Sonata\AdminBundle\Admin\AbstractAdmin->buildForm() in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Admin\AbstractAdmin.php line 1345 at Sonata\AdminBundle\Admin\AbstractAdmin->getForm() in C:\xampp\htdocs\stocks\vendor\sonata-project\admin-bundle\Controller\CRUDController.php line 502 at Sonata\AdminBundle\Controller\CRUDController->createAction() in line at call_user_func_array(array(object(CRUDController), 'createAction'), array()) in C:\xampp\htdocs\stocks\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 144 at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1') in C:\xampp\htdocs\stocks\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 64 at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true) in C:\xampp\htdocs\stocks\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel.php line 69 at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true) in C:\xampp\htdocs\stocks\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php line 185 at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) in C:\xampp\htdocs\stocks\web\app_dev.php line 20
Most helpful comment
The exception has been added to catch this kind of situation where the AdminPool select the last admin defined for the Class. This might lead to error because the target Admin can be wrong.
I need the stack trace to see to source of the error, In case this occurs in a list, you can do:
See https://github.com/sonata-project/ecommerce/blob/develop/src/Sonata/ProductBundle/Admin/ProductCategoryAdmin.php#L56-L58 for more information.