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

Sub object property from ArrayCollection is null #4040

Closed pierre-H closed 4 years ago

pierre-H commented 8 years ago

Environment

Symfony 3.1.3 & Sonata Admin 3.4.0 with Doctrine

Sonata packages

$ composer show sonata-project/*
sonata-project/admin-bundle              3.4.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.1.1 Symfony SonataBlockBundle
sonata-project/cache                     1.0.7 Cache library
sonata-project/core-bundle               3.0.3 Symfony SonataCoreBundle
sonata-project/doctrine-orm-admin-bundle 3.0.5 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.6.0 Lightweight Exporter library

Symfony packages

$ composer show symfony/*
symfony/monolog-bundle     2.11.1  Symfony MonologBundle
symfony/phpunit-bridge     v3.1.3  Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.2.0  Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.2.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.2.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.2.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.2.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.2.0  Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.3.11 Symfony SwiftmailerBundle
symfony/symfony            v3.1.3  The Symfony PHP framework

PHP version

$ php -v
PHP 7.0.4 (cli) (built: Mar  2 2016 15:01:32) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Subject

Value of sub-object from ArrayCollection is null.

Steps to reproduce

I've got an entity EntityA which has a property entitiesB which is an ArrayCollection of EntityB.

EntityB has a property private $helloWorld; with getHelloWorld().

In EntityA I've got a function getLastEntityB() which works perfectly itself and return only one element from the array entitiesB (not the last one : it depends on a date property).

The problem is when I add this code in the list configuration : $listMapper->add('lastEntityB.helloWorld'),

The value is null, but if I add (with toString() ): $listMapper->add('lastEntityB')

It works which means that lastEntityB is not null but when I want to access to helloWorld it's null.

In the show configuration : $showMapper->add('getLastA.b', 'text', array('label'=>'MyLabel')

greg0ire commented 8 years ago

Here is where I think the dot magic happens. You might want to debug that part of the code.

pierre-H commented 8 years ago

Oh thank you ! I will debug this part and let you know ...

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.