Skip to content


Nested CollectionType in an AdminType not working #1228

ClementGautier opened this Issue · 3 comments

2 participants


Hi, I have something like that :


$formMapper->add('article', 'sonata_type_admin', array(), array('edit' => 'inline'))


$formMapper->add('prices', 'sonata_type_collection', array(
  'label' => 'Prices',
  'by_reference' => false,
), array(
  'edit' => 'inline',
  'inline' => 'table',
  'sortable' => 'id'



When I click on "Add new" on the OnlineProduct creation form, the request for append-form-field-element results in a Fatal error:

Fatal error: Call to a member function getName() on a non-object in /var/www/EMO-trunk/app/cache/dev/classes.php on line 15096 Call Stack: 0.0001 688688 1. {main}() /var/www/EMO-trunk/web/app_dev.php:0 0.0307 12134224 2. Symfony\Component\HttpKernel\Kernel->handle() /var/www/EMO-trunk/web/app_dev.php:23 0.1228 17889688 3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle() /var/www/EMO-trunk/app/bootstrap.php.cache:619 0.1228 17891344 4. Symfony\Component\HttpKernel\HttpKernel->handle() /var/www/EMO-trunk/app/bootstrap.php.cache:1568 0.1228 17891344 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /var/www/EMO-trunk/app/bootstrap.php.cache:1392 0.2387 41014520 6. call_user_func_array() /var/www/EMO-trunk/app/bootstrap.php.cache:1428 0.2387 41015008 7. Sonata\AdminBundle\Controller\HelperController->appendFormFieldElementAction() /var/www/EMO-trunk/app/bootstrap.php.cache:0 0.2794 46680336 8. Sonata\AdminBundle\Admin\AdminHelper->appendFormFieldElement() /var/www/EMO-trunk/vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Controller/HelperController.php:84 

It seems that the OnlineProductAdmin is called instead of the ArticleAdmin. So in the AdminHelper, in the appendFormFieldElement method the getChildFormBuilder method returns null. I see a note in top of the method telling me that this function does not work with nested elements.

Is it a known issue or I am doing it wrong ? How can I deal with it ?

I tried a quick fix and I'm now able to get the childFormBuilder but then its the getFormFieldDescription who returning a null value. Do I have to add a child admin in the ArticleAdmin ?

Thanks for the help.


Note: Only the "New" and "Delete" action are affected, I can successfully update an existing row.


The delete issue was something else ( I missed the orphanRemoval )



Possible duplicate of


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.