sonata-project / SonataDoctrineORMAdminBundle

Integrate Doctrine ORM into the SonataAdminBundle
https://docs.sonata-project.org/projects/SonataDoctrineORMAdminBundle
MIT License
444 stars 345 forks source link

Filtering a "false" element in dasboard returns empty set #873

Closed checcoux closed 4 years ago

checcoux commented 5 years ago

Environment

Sonata packages

sonata-project/admin-bundle              3.40.2 3.43.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.12.1 3.13.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.11.2 3.13.4 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.4.0  2.4.0  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.6.3  3.6.3  Symfony Sonata / Integrate Doctrine ORM into the So...
sonata-project/exporter                  1.9.1  1.10.0 Lightweight Exporter library

Symfony packages

symfony/filesystem         v2.8.47 v4.2.1  Symfony Filesystem Component
symfony/monolog-bundle     v3.3.1  v3.3.1  Symfony MonologBundle
symfony/phpunit-bridge     v3.4.18 v4.2.1  Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.10.0 v1.10.0 Symfony polyfill backporting apcu_* functions to lower PHP vers...
symfony/polyfill-ctype     v1.10.0 v1.10.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-icu  v1.10.0 v1.10.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.10.0 v1.10.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 5.6+ features to lower PH...
symfony/polyfill-php70     v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 7.0+ features to lower PH...
symfony/polyfill-util      v1.10.0 v1.10.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  v3.2.4  Symfony SwiftmailerBundle
symfony/symfony            v3.4.18 v4.2.1  The Symfony PHP framework
symfony/templating         v4.1.7  v4.2.1  Symfony Templating Component

PHP version

PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Subject

Working with filters in the admin dasboard. I have a boolean value that is displayed correctly with a "yes" or "no" value in the list. If I create a filter with all of the "yes" values it works, while if I do the same but i filter with "no" values, it returns an empty set.

Steps to reproduce

my UserAdmin class

//...
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('id')
            ->add('username')
            ->add('email')
            ->add('autorizzato'); //this is the boolean value
    }

Expected results

It should display "no" values as it does with "yes" values.

Actual results

Does not display "no" values.

All of the users

screen shot 2018-12-18 at 14 58 49

"yes" users

screen shot 2018-12-18 at 14 59 09

"no" users

screen shot 2018-12-18 at 14 59 26
lukepass commented 5 years ago

Is your autorizzato field a Doctrine mapped field? For me it's working fine:

image

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('name')
        ->add('phone')
        ->add('default')
    ;
}

What query is being executed in the profiler?

OskarStark commented 5 years ago

Are you sure it is false and not “null” ?

sirbaconjr commented 5 years ago

Something like this happened to me a few days ago. The problem was that my values were NULL, but no danger label was being rendered. Which cause some confusion for me and for the users.

Maybe the filter should work with null? Or maybe the display could be different? Or maybe this is not needed at all since it is a problem with the developer code. In my quase it was a malformed query.

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.

checcoux commented 4 years ago

in the end i was expecting the no danger label rendered with NULL values. i was kinda confused, why is not possible to render the no danger label with NULL values? like @ejkun i like the idea of showing that label with NULL label; maybe if you want to show only no and not NULL you could write another filter