sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Nested sonata_type_collection error: could not get id #4752

Closed ger86 closed 4 years ago

ger86 commented 7 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.24.0 3.24.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.2  3.5.0  Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  2.0.0  Cache library
sonata-project/core-bundle               3.4.0  3.6.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1  2.2.1  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.1.6  3.1.7  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.7.1  1.7.1  Lightweight Exporter library

Symfony packages

$ composer show --latest 'symfony/*'
symfony/assetic-bundle     v2.8.2 v2.8.2  Integrates Assetic into Symfony2
symfony/monolog-bundle     v3.1.0 v3.1.2  Symfony MonologBundle
symfony/phpunit-bridge     v3.3.6 v3.3.10 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.4.0 v1.6.0  Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.4.0 v1.6.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.4.0 v1.6.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.4.0 v1.6.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.4.0 v1.6.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.4.0 v1.6.0  Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0 v3.0.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.3 v3.1.6  Symfony SwiftmailerBundle
symfony/symfony            v3.3.6 v3.3.10 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.1 (cli) (built: Jan 23 2017 15:09:57) ( NTS )

Subject

If I have a Admin class with a sonata_type_collection and the associated admin for that collection has another sonata_type_collection, trying to add a element causes the following 500 error:

Could not get element id from s5a033b8528778_proposals_0_services Failing part: services

Steps to reproduce

class NegotiationAdmin extends Admin {

    protected function configureFormFields(FormMapper $formMapper) {
        $formMapper
                 ->add('proposals', 'sonata_type_collection', [
                    'required' => false,
                    'by_reference' => false,
                    'label' => 'Propuestas',
                    ], [
                        'edit' => 'inline',
                        'inline' => 'standard'
                    ]
                )
class ProposalAdmin extends Admin {

    protected function configureFormFields(FormMapper $formMapper) {
        $formMapper
            ->with('Servicios')
                ->add('services', 'sonata_type_collection', [
                    'required' => false,
                    'by_reference' => false,
                    'label' => 'Servicios ofrecidos',
                    ], [
                        'edit' => 'inline',
                        'inline' => 'standard'
                    ]
                )

Expected results

Add a new element row for the field services in ProposalAdmin embedded into NegotiationAdmin

captura de pantalla 2017-11-08 a las 18 18 40

Actual results

Could not get element id from s5a033b8528778_proposals_0_services Failing part: services

Exception:
Could not get element id from s5a033b8528778_proposals_0_services Failing part: services

  at vendor/sonata-project/admin-bundle/Admin/AdminHelper.php:283
  at Sonata\AdminBundle\Admin\AdminHelper->getElementAccessPath('s5a033b8528778_proposals_0_services', object(Negotiation))
     (vendor/sonata-project/admin-bundle/Admin/AdminHelper.php:127)
  at Sonata\AdminBundle\Admin\AdminHelper->appendFormFieldElement(object(NegotiationAdmin), object(Negotiation), 's5a033b8528778_proposals_0_services')
     (vendor/sonata-project/admin-bundle/Controller/HelperController.php:107)
  at Sonata\AdminBundle\Controller\HelperController->appendFormFieldElementAction(object(Request))
  at call_user_func_array(array(object(HelperController), 'appendFormFieldElementAction'), array(object(Request)))
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:153)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:171)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:29)
stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.