Sonataadminbundle: error with sonata_type_admin

Created on 27 Mar 2017  Â·  18Comments  Â·  Source: sonata-project/SonataAdminBundle

Environment

Sonata packages

$ composer show sonata-project/*
sonata-project/admin-bundle              3.15.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.2  Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  Cache library
sonata-project/core-bundle               3.3.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.1.4  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.7.1  Lightweight Exporter library

Symfony packages

$ composer show symfony/*
symfony/monolog-bundle     v3.1.0 Symfony MonologBundle
symfony/phpunit-bridge     v3.2.6 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.3.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.3.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.3.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.3.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.3.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.3.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.5.4 Symfony SwiftmailerBundle
symfony/symfony            v3.2.6 The Symfony PHP framework

PHP version

$ php -v
PHP 7.0.15-0ubuntu0.16.10.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
    with Zend OPcache v7.0.15-0ubuntu0.16.10.4, Copyright (c) 1999-2017, by Zend Technologies

Subject

I think it's related to
https://github.com/sonata-project/SonataAdminBundle/commit/3a75cad5e1d6e6e6dfcd8d639c5c4f8fb6678152

Steps to reproduce

/**
 * @param FormMapper $formMapper
 */
protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
      ->add('address', 'sonata_type_admin', array(
          'label' => false,
      ))
    ;
}

Expected results

many fields from Address Admin

Actual results

error:

Neither the property "addressaddress" nor one of the methods "getAddressaddress()", "addressaddress()", "isAddressaddress()", "hasAddressaddress()", "__get()" exist and have public access in class User
bug critical

All 18 comments

I think it's related to 0587255

Are you sure? That's not the commit you commended on

ping @lalop can you help?

@axzx I don't see how this can be related to this commit...

@axzx did you find this with git bisect ?

I checked every commits from 3.14.0 and after this:

- Updating sonata-project/admin-bundle 3.x-dev (b7d657b => 3a75cad):  Checking out 3a75cad5e1

I have an error.

@axzx is right because I have the same error after that update. I don't know why it doesn't work. However, I've solved it passing 'data' option to the AdminType field

->add('configurationGenerator', AdminType::class,
        array(
             'data' => (!$this->getSubject()->getId()) ? new ConfigurationGenerator() : $this->getSubject()->getConfigurationGenerator(),
             'label' => false
        ),
        array(
              'admin_code' => 'sonata.admin.configuration_generator',
              'edit' => 'inline'
        )
)

This is serious BC break that should be fixed ASAP.

I think we could revert 3a75cad if no solution is found by tomorrow.

@axzx can you give the complete code of your admin class please ?

thank you @axzx
The addressaddress come from this line https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Form/Type/AdminType.php#L82

Since I added the property_path for each field this line broke the path...

I think this should be fixed in AdminType since all the other form's type seems to work correctly but I'm not sure to understand the initial implementation bewind this option.

@pulzarraider maybe you can explain this ?

@axzx a kick fix could be to add 'property_path' => '' in field's options

So… shall I revert this?

I'm experiencing the same problem (in my case it's "countercounter", 'cause my field's name is counter).

As I see @greg0ire you're already working on a bugfix. Can I help?

Imo we should add a failing test case and try to fix this

It's merely a revert, I'm not really creating anything here. There's not much you can do to help, except maybe find a proper fix

I'll take a look. Until this is fixed, I've downgraded sonata-project/admin-bundle to 3.14.0, which fixes the problem for now.

Was this page helpful?
0 / 5 - 0 ratings