Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Nested CollectionType in an AdminType not working #1228

ClementGautier opened this Issue Mar 18, 2013 · 4 comments


None yet
3 participants

ClementGautier commented Mar 18, 2013

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.


ClementGautier commented Mar 18, 2013

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


ClementGautier commented Mar 18, 2013

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


webdevilopers commented Mar 27, 2015


Possible duplicate of



core23 commented Aug 13, 2016

This issue is very old. Can you please check this against the latest master version?

Feel free to reopen if this error still exists.

@core23 core23 closed this Aug 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment