Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Nested CollectionType in an AdminType not working #1228

Open
ClementGautier opened this Issue · 2 comments

1 participant

Clément Gautier
Clément Gautier

Hi, I have something like that :

OnlineProductAdmin

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

ArticleAdmin:

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

PriceAdmin:

$formMapper
  ->add('price')
  ->add('currency');

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.

Clément Gautier

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

Clément Gautier

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

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.