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

ChoiceFieldMaskType inside ModelListType does not work #5730

Closed youngdolphin closed 4 years ago

youngdolphin commented 4 years ago

Environment

CMS built using Symfony 3.4 and Sonata Admin.

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.49.1 ! 3.54.1 The missing Symfony Admin Generator
sonata-project/block-bundle              3.18.1 = 3.18.1 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  = 2.0.1  Cache library
sonata-project/core-bundle               3.17.0 = 3.17.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0  ~ 3.0.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.3.1  = 1.3.1  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.10.0 = 3.10.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdm...
sonata-project/easy-extends-bundle       2.5.0  = 2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1  = 2.0.1  Lightweight Exporter library
sonata-project/media-bundle              3.20.1 ! 3.21.0 Symfony SonataMediaBundle
sonata-project/translation-bundle        2.4.2  = 2.4.2  SonataTranslationBundle
sonata-project/user-bundle               4.4.0  ! 4.5.1  Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/http-client           v4.3.5  = v4.3.5  Symfony HttpClient component
symfony/http-client-contracts v1.1.7  = v1.1.7  Generic abstractions related to HTTP clients
symfony/mime                  v4.3.5  = v4.3.5  A library to manipulate MIME messages
symfony/monolog-bundle        v3.4.0  = v3.4.0  Symfony MonologBundle
symfony/phpunit-bridge        v4.3.5  = v4.3.5  Symfony PHPUnit Bridge
symfony/polyfill-apcu         v1.12.0 = v1.12.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype        v1.12.0 = v1.12.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-icu     v1.12.0 = v1.12.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn     v1.12.0 = v1.12.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring     v1.12.0 = v1.12.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56        v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP ve...
symfony/polyfill-php70        v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP ve...
symfony/polyfill-php72        v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP ve...
symfony/polyfill-php73        v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP ve...
symfony/polyfill-util         v1.12.0 = v1.12.0 Symfony utilities for portability of PHP codes
symfony/security-acl          v3.0.2  = v3.0.2  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle    v2.6.7  ~ v3.3.0  Symfony SwiftmailerBundle
symfony/symfony               v3.4.26 ~ v4.3.5  The Symfony PHP framework

PHP version

$ php -v
PHP 7.2.22 (cli) (built: Aug 28 2019 09:29:01) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Subject

I have an entity with a property with a ManyToOne relation to another entity. It works fine and if i use the ModelType in the property i can see the right result of the ChoiceFieldMaskType in the modal to add a new entity. The problem is that if i use ModelListType instead of ModelType and i try to add a new entity, the tab with the form to add the new Step does not consider ChoiceFieldMaskType and shows every property of the entity. (This bug is probably related to https://github.com/sonata-project/SonataAdminBundle/issues/4911)

Steps to reproduce

Create two entity, one refers to the other with a ManyToOne (or OneToOne) relation and uses ModelListType in the admin, and the other has a field using ChoiceFieldMaskType in the admin. Then, in the admin, click the add button to add a new entity in the ModelListType menu.

Expected results

The add modal shows only the properties based on ChoiceFieldMaskType.

Actual results

The add modal shows every property of the entity.

Thanks

youngdolphin commented 4 years ago

It is actually a different bug, the modal to add a new entity works only the first time you open it, then if you want to add a new entity in the same admin page it stops to work (this bug is in ModalListType and in the ModalType too).