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

Data Transformers in list fields editable #5693

Closed peter-gribanov closed 4 years ago

peter-gribanov commented 5 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.52.0 3.53.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.12.1 3.18.0 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.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.3.0  1.3.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.9.0  3.10.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter library

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.4.0  v3.4.0  Symfony MonologBundle
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-iconv     v1.12.0 v1.12.0 Symfony polyfill for the Iconv extension
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 versions
symfony/polyfill-php70     v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72     v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
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 v3.2.8  v3.2.8  Symfony SwiftmailerBundle
symfony/symfony            v3.4.31 v4.3.4  The Symfony PHP framework

PHP version

$ php -v
PHP 7.3.9 (cli) (built: Sep  3 2019 06:20:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.9, Copyright (c) 1999-2018, by Zend Technologies

Subject

I can use DataTransformer in configureFormFields(), but i can not use it in configureListFields(). Need add ability to use a DataTransformer in configureListFields(). Perhaps a related issue #5691.

Steps to reproduce

Make entity

class ContestantAdminView
{
    // ...

    public function setPermission(Permission $permission): void
    {
        $this->permission = $permission;
    }
}

Configure field as editable in admin service

class TestimonialAdmin extends BaseAdmin
{
    // ...

    protected function configureListFields(ListMapper $list_mapper): void
    {
        $list_mapper
            ->add('permission', 'choice', [
                'label' => 'Permission',
                'editable' => true,
                'choices' => Permission::change(),
                'template' => '@Frontend/Testimonial/admin/list_permission.html.twig',
                'catalogue' => 'messages',
            ])
        ;
    }

Go to admin. Change the permission and chose some value

image

Expected results

The Permission object is expected.

Actual results

Click submit and get 500 error because string comes

image

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.

peter-gribanov commented 4 years ago

Yes. This issue is still relevant. I still haven’t received any feedback.

peter-gribanov commented 4 years ago

@core23 why you ping me?

buxom-man commented 4 years ago

I have the same issue trying to save an empty field which cannot be empty. Validation does not work

peter-gribanov commented 4 years ago

@buxom-man maybe this is your problem #5691 please check

VincentLanglet commented 4 years ago

@peter-gribanov Do you want to implement the feature ? I see no reason for not merging this.

peter-gribanov commented 4 years ago

@VincentLanglet i create PR for this feature #5937

github-actions[bot] commented 4 years ago

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

peter-gribanov commented 4 years ago

This issue is still relevant. We are waiting PR #5937