Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export not working when sorting on second level ManyToOne column #1825

Open
ARodnovs opened this issue Jan 27, 2025 · 0 comments
Open

Export not working when sorting on second level ManyToOne column #1825

ARodnovs opened this issue Jan 27, 2025 · 0 comments

Comments

@ARodnovs
Copy link

ARodnovs commented Jan 27, 2025

Environment

Sonata packages

show

$ composer show --latest 'sonata-project/*'
# Put the result here.

Direct dependencies required in composer.json:

sonata-project/admin-bundle 4.29.2 4.34.0 The missing Symfony Admin Generator
sonata-project/doctrine-orm-admin-bundle 4.15.0 4.17.1 Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/user-bundle 5.10.0 5.14.0 Symfony SonataUserBundle

Transitive dependencies not required in composer.json:
sonata-project/block-bundle 5.1.0 5.1.1 Symfony SonataBlockBundle
sonata-project/doctrine-extensions 2.3.0 2.4.1 Doctrine2 behavioral extensions
sonata-project/exporter 3.3.0 3.3.0 Lightweight Exporter library
sonata-project/form-extensions 2.3.0 2.4.0 Symfony form extensions
sonata-project/twig-extensions 2.4.0 2.5.0 Sonata twig extensions

Symfony packages

show

$ composer show --latest 'symfony/*'
# Put the result here.

Color legend:

  • patch or minor release available - update recommended
  • major release available - update possible
  • up to date version

Direct dependencies required in composer.json:
symfony/apache-pack v1.0.1 v1.0.1 A pack for Apache support in Symfony
symfony/asset v5.4.31 v7.2.0 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and ima...
symfony/browser-kit v5.4.31 v7.2.0 Simulates the behavior of a web browser, allowing you to make requests, click on links and submit for...
symfony/console v5.4.34 v7.2.1 Eases the creation of beautiful and testable command line interfaces
symfony/css-selector v5.4.26 v7.2.0 Converts CSS selectors to XPath expressions
symfony/debug-bundle v5.4.35 v7.2.0 Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from Monolog...
symfony/doctrine-messenger v5.4.34 v7.2.2 Symfony Doctrine Messenger Bridge
symfony/dotenv v5.4.34 v7.2.0 Registers environment variables from a .env file
symfony/expression-language v5.4.21 v7.2.0 Provides an engine that can compile and evaluate expressions
symfony/flex v2.4.3 v2.4.7 Composer plugin for Symfony
symfony/form v5.4.33 v7.2.0 Allows to easily create, process and reuse HTML forms
symfony/framework-bundle v5.4.34 v7.2.2 Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client v5.4.34 v7.2.2 Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/intl v5.4.30 v7.2.0 Provides a PHP replacement layer for the C intl extension that includes additional data from the ICU ...
symfony/mailer v5.4.34 v7.2.0 Helps sending emails
symfony/maker-bundle v1.50.0 v1.62.1 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can f...
symfony/mime v5.4.26 v7.2.1 Allows manipulating MIME messages
symfony/monolog-bundle v3.10.0 v3.10.0 Symfony MonologBundle
symfony/notifier v5.4.31 v7.2.0 Sends notifications via one or more channels (email, SMS, ...)
symfony/phpunit-bridge v7.0.2 v7.2.0 Provides utilities for PHPUnit, especially user deprecation notices management
symfony/process v5.4.34 v7.2.0 Executes commands in sub-processes
symfony/property-access v5.4.26 v7.2.0 Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info v5.4.24 v7.2.2 Extracts information about PHP class' properties using metadata of popular sources
symfony/runtime v5.4.26 v7.2.0 Enables decoupling PHP applications from global state
symfony/security-bundle v5.4.34 v7.2.2 Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/serializer v5.4.34 v7.2.0 Handles serializing and deserializing data structures, including object graphs, into array structures...
symfony/stimulus-bundle v2.14.2 v2.22.1 Integration with your Symfony app & Stimulus!
symfony/stopwatch v5.4.21 v7.2.2 Provides a way to profile code
symfony/string v5.4.34 v7.2.0 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clust...
symfony/translation v5.4.31 v7.2.2 Provides tools to internationalize your application
symfony/twig-bundle v5.4.31 v7.2.0 Provides a tight integration of Twig into the Symfony full-stack framework
symfony/validator v5.4.34 v7.2.2 Provides tools to validate values
symfony/web-link v5.4.21 v7.2.0 Manages links between resources
symfony/web-profiler-bundle v5.4.36 v7.2.2 Provides a development tool that gives detailed information about the execution of any request
symfony/webpack-encore-bundle v2.1.1 v2.2.0 Integration with your Symfony app & Webpack Encore!
symfony/yaml v5.4.31 v7.2.0 Loads and dumps YAML files

Transitive dependencies not required in composer.json:
symfony/amqp-messenger v5.4.31 v5.4.45 Symfony AMQP extension Messenger Bridge
symfony/cache v5.4.34 v7.2.1 Provides extended PSR-6, PSR-16 (and tags) implementations
symfony/cache-contracts v2.5.2 v3.5.1 Generic abstractions related to caching
symfony/config v5.4.31 v7.2.0 Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/dependency-injection v5.4.34 v7.2.0 Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts v3.4.0 v3.5.1 A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge v5.4.34 v7.2.2 Provides integration for Doctrine with various Symfony components
symfony/dom-crawler v5.4.32 v7.2.0 Eases DOM navigation for HTML and XML documents
symfony/error-handler v5.4.29 v7.2.1 Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher v5.4.34 v7.2.0 Provides tools that allow your application components to communicate with each other by dispatching e...
symfony/event-dispatcher-contracts v3.4.0 v3.5.1 Generic abstractions related to dispatching event
symfony/filesystem v5.4.25 v7.2.0 Provides basic utilities for the filesystem
symfony/finder v5.4.27 v7.2.2 Finds files and directories via an intuitive fluent interface
symfony/http-client-contracts v2.5.2 v3.5.2 Generic abstractions related to HTTP clients
symfony/http-foundation v5.4.34 v7.2.2 Defines an object-oriented layer for the HTTP specification
symfony/http-kernel v5.4.34 v7.2.2 Provides a structured process for converting a Request into a Response
symfony/messenger v5.4.31 v7.2.1 Helps applications send and receive messages to/from other applications or via message queues
symfony/monolog-bridge v5.4.31 v7.2.0 Provides integration for Monolog with various Symfony components
symfony/options-resolver v5.4.21 v7.2.0 Provides an improved replacement for the array_replace PHP function
symfony/password-hasher v5.4.31 v7.2.0 Provides password hashing utilities
symfony/polyfill-intl-grapheme v1.28.0 v1.31.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu v1.28.0 v1.31.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn v1.28.0 v1.31.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer v1.28.0 v1.31.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.28.0 v1.31.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php73 v1.28.0 v1.31.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80 v1.28.0 v1.31.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81 v1.28.0 v1.31.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/redis-messenger v5.4.34 v7.2.0 Symfony Redis extension Messenger Bridge
symfony/routing v5.4.34 v7.2.0 Maps an HTTP request to a set of configuration variables
symfony/security-acl v3.3.3 v3.3.4 Symfony Security Component - ACL (Access Control List)
symfony/security-core v5.4.30 v7.2.0 Symfony Security Component - Core Library
symfony/security-csrf v5.4.27 v7.2.2 Symfony Security Component - CSRF Library
symfony/security-guard v5.4.27 v5.4.45 Symfony Security Component - Guard
symfony/security-http v5.4.31 v7.2.1 Symfony Security Component - HTTP Integration
symfony/service-contracts v2.5.2 v3.5.1 Generic abstractions related to writing services
symfony/translation-contracts v2.5.2 v3.5.1 Generic abstractions related to translation
symfony/twig-bridge v5.4.34 v7.2.2 Provides integration for Twig with various Symfony components
symfony/var-dumper v5.4.29 v7.2.0 Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter v6.4.2 v7.2.0 Allows exporting any serializable PHP data structure to plain PHP code

PHP version

$ php -v
# Put the result here.

PHP 8.2.27 (cli) (built: Dec 24 2024 22:26:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.27, Copyright (c) Zend Technologies
with Zend OPcache v8.2.27, Copyright (c), by Zend Technologies
with Xdebug v3.4.1, Copyright (c) 2002-2025, by Derick Rethans

Subject

Original issue -> #1586

Still reproduces if property has 2+ level relation.

Minimal repository with the bug

Steps to reproduce

Entity definitions:

RequestItem Class:

/**
 * @var Request $request
 *
 * @ORM\ManyToOne(targetEntity="Request", inversedBy="items")
 * @ORM\JoinColumn(name="request_id", referencedColumnName="request_id")
 * @Gedmo\Versioned
 */
protected $request;

Request Class:

/**
 * @var Client $client
 *
 * @ORM\ManyToOne(targetEntity="Client")
 * @ORM\JoinColumn(name="client_id", referencedColumnName="client_id")
 * @Assert\NotBlank()
 * @Gedmo\Versioned
 */
protected $client; 

Client Class:

/**
 * @var string $name
 *
 * @ORM\Column(name="name", type="string", length=255)
 * @Assert\NotBlank()
 * @Gedmo\Versioned
 */
protected $name;

I have this "Admin" definitions:

public function configureListFields(ListMapper $list): void
    {
        $list
            ->add('request.client', null, [
                    'column_definition' => [
                        'wrapText' => true,
                        'autoHeight' => true,
                    ],
                    'label' => 'list.label_client',
                    'sortable' => true,
                    'sort_field_mapping' => [
                        'fieldName' => 'name',
                    ],
                    'sort_parent_association_mappings' => [
                        ['fieldName' => 'request'],
                        ['fieldName' => 'client'],
                    ],
                ]
            );
    }

When I sort on the column "request.client". The list overview works fine and the results are sorted. But when I want to export these results, I get:
No mapping found for field 'client' on class 'App\Entity\RequestItem'.

Expected results

The exporter to export the results sorted

Actual results

No mapping error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant