a2lix / TranslationFormBundle

Ease translations with some dedicated Symfony form types
https://a2lix.fr/bundles/translation-form
MIT License
331 stars 138 forks source link

EasyAdmin using list sorting #335

Closed byhaskell closed 2 years ago

byhaskell commented 5 years ago

Environment

Symfony packages

symfony/asset                      v4.3.4  = v4.3.4  Symfony Asset Component
symfony/browser-kit                v4.3.4  = v4.3.4  Symfony BrowserKit Component
symfony/cache                      v4.3.4  = v4.3.4  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v1.1.5  = v1.1.5  Generic abstractions related to caching
symfony/config                     v4.3.4  = v4.3.4  Symfony Config Component
symfony/console                    v4.3.4  = v4.3.4  Symfony Console Component
symfony/css-selector               v4.3.4  = v4.3.4  Symfony CssSelector Component
symfony/debug                      v4.3.4  = v4.3.4  Symfony Debug Component
symfony/debug-bundle               v4.3.4  = v4.3.4  Symfony DebugBundle
symfony/debug-pack                 v1.0.7  = v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection       v4.3.4  = v4.3.4  Symfony DependencyInjection Component
symfony/doctrine-bridge            v4.3.4  = v4.3.4  Symfony Doctrine Bridge
symfony/dom-crawler                v4.3.4  = v4.3.4  Symfony DomCrawler Component
symfony/dotenv                     v4.3.4  = v4.3.4  Registers environment variables from a .env file
symfony/event-dispatcher           v4.3.4  = v4.3.4  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.5  = v1.1.5  Generic abstractions related to dispatching event
symfony/expression-language        v4.3.4  = v4.3.4  Symfony ExpressionLanguage Component
symfony/filesystem                 v4.3.4  = v4.3.4  Symfony Filesystem Component
symfony/finder                     v4.3.4  = v4.3.4  Symfony Finder Component
symfony/flex                       v1.4.5  ! v1.4.6  Composer plugin for Symfony
symfony/form                       v4.3.4  = v4.3.4  Symfony Form Component
symfony/framework-bundle           v4.3.4  = v4.3.4  Symfony FrameworkBundle
symfony/http-client                v4.3.4  = v4.3.4  Symfony HttpClient component
symfony/http-client-contracts      v1.1.6  = v1.1.6  Generic abstractions related to HTTP clients
symfony/http-foundation            v4.3.4  = v4.3.4  Symfony HttpFoundation Component
symfony/http-kernel                v4.3.4  = v4.3.4  Symfony HttpKernel Component
symfony/inflector                  v4.3.4  = v4.3.4  Symfony Inflector Component
symfony/intl                       v4.3.4  = v4.3.4  A PHP replacement layer for the C intl extension that includes...
symfony/maker-bundle               v1.13.0 = v1.13.0 Symfony Maker helps you create empty commands, controllers, fo...
symfony/mime                       v4.3.4  = v4.3.4  A library to manipulate MIME messages
symfony/monolog-bridge             v4.3.4  = v4.3.4  Symfony Monolog Bridge
symfony/monolog-bundle             v3.4.0  = v3.4.0  Symfony MonologBundle
symfony/options-resolver           v4.3.4  = v4.3.4  Symfony OptionsResolver Component
symfony/orm-pack                   v1.0.6  = v1.0.6  A pack for the Doctrine ORM
symfony/panther                    v0.5.2  = v0.5.2  A browser testing and web scraping library for PHP and Symfony.
symfony/phpunit-bridge             v4.3.4  = v4.3.4  Symfony PHPUnit Bridge
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 funct...
symfony/polyfill-mbstring          v1.12.0 = v1.12.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 7.2+ features to lower P...
symfony/polyfill-php73             v1.12.0 = v1.12.0 Symfony polyfill backporting some PHP 7.3+ features to lower P...
symfony/process                    v4.3.4  = v4.3.4  Symfony Process Component
symfony/profiler-pack              v1.0.4  = v1.0.4  A pack for the Symfony web profiler
symfony/property-access            v4.3.4  = v4.3.4  Symfony PropertyAccess Component
symfony/property-info              v4.3.4  = v4.3.4  Symfony Property Info Component
symfony/routing                    v4.3.4  = v4.3.4  Symfony Routing Component
symfony/security-bundle            v4.3.4  = v4.3.4  Symfony SecurityBundle
symfony/security-core              v4.3.4  = v4.3.4  Symfony Security Component - Core Library
symfony/security-csrf              v4.3.4  = v4.3.4  Symfony Security Component - CSRF Library
symfony/security-guard             v4.3.4  = v4.3.4  Symfony Security Component - Guard
symfony/security-http              v4.3.4  = v4.3.4  Symfony Security Component - HTTP Integration
symfony/serializer                 v4.3.4  = v4.3.4  Symfony Serializer Component
symfony/serializer-pack            v1.0.2  = v1.0.2  A pack for the Symfony serializer
symfony/service-contracts          v1.1.6  = v1.1.6  Generic abstractions related to writing services
symfony/stopwatch                  v4.3.4  = v4.3.4  Symfony Stopwatch Component
symfony/swiftmailer-bundle         v3.2.8  = v3.2.8  Symfony SwiftmailerBundle
symfony/templating                 v4.3.4  = v4.3.4  Symfony Templating Component
symfony/test-pack                  v1.0.6  = v1.0.6  A pack for functional and end-to-end testing within a Symfony app
symfony/translation                v4.3.4  = v4.3.4  Symfony Translation Component
symfony/translation-contracts      v1.1.6  = v1.1.6  Generic abstractions related to translation
symfony/twig-bridge                v4.3.4  = v4.3.4  Symfony Twig Bridge
symfony/twig-bundle                v4.3.4  = v4.3.4  Symfony TwigBundle
symfony/validator                  v4.3.4  = v4.3.4  Symfony Validator Component
symfony/var-dumper                 v4.3.4  = v4.3.4  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.3.4  = v4.3.4  A blend of var_export() + serialize() to turn any serializable...
symfony/web-link                   v4.3.4  = v4.3.4  Symfony WebLink Component
symfony/web-profiler-bundle        v4.3.4  = v4.3.4  Symfony WebProfilerBundle
symfony/web-server-bundle          v4.3.4  = v4.3.4  Symfony WebServerBundle
symfony/yaml                       v4.3.4  = v4.3.4  Symfony Yaml Component

PHP version

PHP 7.2.0 (cli) (built: Nov 28 2017 23:48:49) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

Subject

            list:
                fields:
                    - { property: 'translations', label: 'title', type: A2lix\TranslationFormBundle\Form\Type\TranslationsType ,
                        type_options: {
                            required: true,
                            default_locale: '%locale%',
                            fields: { title: {field_type: 'Symfony\Component\Form\Extension\Core\Type\TextType', label: 'title' } }
                        }
                      }

When using this type, you cannot sort the field; an error appears. An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 60 near 'translations': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.").

When using this type of recording:

                fields:
                    - { property: 'title', label: 'title', sortable: true }

getting an error: An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 60 near 'title DESC': Error: Class App\Entity\Events has no field or association named title").

tchapi commented 2 years ago

Hi @byhaskell

This is expected since your Events entity has no field title (I guess it resides in EventTranslation). Easy Admin uses Doctrine to sort fields (adding ORDER BY clauses where necessary) but at the moment it cannot do so on associations for instance, so I'm afraid it's not possible.

See https://symfony.com/bundles/EasyAdminBundle/current/fields.html#misc-options :

"unmapped fields and Doctrine associations cannot be sorted"