How to show null value with NumericFilter in EasyAdmin


I’ve got a field ‘shopSurface’ which is nullable and not required.
In EA I added a NumericFilter:
NumericFilter::new('shopSurface', 'shop_surface').
If I want all the entries which have not shopSurface I look for equal to and I leave empty the field but nothing appear, the list is empty while I have some.

Do you know a way to make it appear ?


This is how I did :

public function apply(QueryBuilder $queryBuilder, FilterDataDto $filterDataDto, ?FieldDto $fieldDto, EntityDto $entityDto): void
        $alias = $filterDataDto->getEntityAlias();
        $property = $filterDataDto->getProperty();
        $comparison = $filterDataDto->getComparison();
        $parameterName = $filterDataDto->getParameterName();
        $parameter2Name = $filterDataDto->getParameter2Name();
        $value = $filterDataDto->getValue();
        $value2 = $filterDataDto->getValue2();

        if (ComparisonType::BETWEEN === $comparison) {
            $queryBuilder->andWhere(sprintf('%s.%s BETWEEN :%s and :%s', $alias, $property, $parameterName, $parameter2Name))
                ->setParameter($parameterName, $value)
                ->setParameter($parameter2Name, $value2);
        } else {
            $queryBuilder->andWhere(sprintf('%s.%s %s :%s', $alias, $property, $comparison, $parameterName))
                ->setParameter($parameterName, $value);

        if (ComparisonType::EQ === $comparison && '' === $value){
            $queryBuilder->andWhere(sprintf('%s IS NULL', $alias));


You have 2 solutions :

  • Add a NullFilter in addition to your NumericFilter to show null values (all built-in filters are avalables here)


  • Add your custom filter like that (doc here).

If you need some help do not hesitate.

Answered By – vinceAmstoutz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published