Sonataadminbundle: Impossible filter a list by empty value

Created on 2 Feb 2016  路  17Comments  路  Source: sonata-project/SonataAdminBundle

For example:

  • I want to find all users who do not have group
  • I want to find all users who have not specified a surname

Now, if you leave the filter empty, it does not apply. If you search for a null value via callback, it always applies, even if i did not choose filters.

enhancement

Most helpful comment

Please stop spamming +1 comments. Somebody needs to start a PR for this.

Maybe @danielsippel or @muspelheim ?

All 17 comments

+1

+1

Please stop spamming +1 comments. Somebody needs to start a PR for this.

Maybe @danielsippel or @muspelheim ?

Can you provide a PR with the proposed change? Thanks

Hi, as asked here https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/991#issuecomment-595868272, can you be more precise with the needs ?
What is an empty value ?

If not we could consider this issue as resolved since

  • I want to find all users who do not have group
  • I want to find all users who have not specified a surname

Where group.id IS NULL
Where surname IS NULL

Can be both made by the ChoiceFilter now.

For what I know, you now only miss the filter Where surname = '', isn't it ?

  • I want to find all users who have not specified a surname

Where surname IS NULL

NULL is not a valid value for a string column.

For what I know, you now only miss the filter聽Where surname = '', isn't it ?

Yes. This is the main case.

This issue was created more than 4 years ago. Now for me this is not so relevant.

Can be both made by the ChoiceFilter now.

I can't check now, but is this relevant for?

  • NumberFilter
  • StringFilter
  • DateTimeFilter
  • DateFilter
  • TimeFilter
  • DateTimeRangeFilter
  • DateRangeFilter
  • ModelAutocompleteFilter
  • ClassFilter

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.

This issue has not been resolved yet

Do you want to work on a PR @peter-gribanov ?

@VincentLanglet I see only one way to solve this problem. Filter by empty value only if the filtering type is explicitly specified (not specified by default).

I think there is a big reflexion needed about the UX of this kind of filters.
Also this is maybe not a behavior that everybody's looking for.

This could be solved by

  • An option
  • Specific filters
  • Some UX changements.

Specific filters

Any filter will not be applied if the filter value is empty. For more details see here #6402
I see no reason to create a new filter if it can be done within the existing one.

I think there is a big reflexion needed about the UX of this kind of filters.

Let me explain how i see it.

This is how the filter string looks when we decide to filter the data. In this form, the filter will not be applied.
image

We can enable advanced filtering mode, but this filter will still not be applied.
image

If we explicitly indicate the typhus of filtering, then we let the system know that we want to search for an empty string. And we don't want the system to ignore this filter.
image

Specific filters

Any filter will not be applied if the filter value is empty. For more details see here #6402

That's a good point.

I think there is a big reflexion needed about the UX of this kind of filters.

Let me explain how i see it.

This is how the filter string looks when we decide to filter the data. In this form, the filter will not be applied.
image

We can enable advanced filtering mode, but this filter will still not be applied.
image

If we explicitly indicate the typhus of filtering, then we let the system know that we want to search for an empty string. And we don't want the system to ignore this filter.
image

If after your third step you disable again the advanced filtering mode, you'll get
image

You won't be able to know if this filter will be applied or not. That's my only concern.

We can define through JS that a search will be performed on an empty string and add help text in these cases.

image
image

@VincentLanglet this is just a suggestion for improving UI. I do not understand your JS and i cannot do it.

@VincentLanglet this is just a suggestion for improving UI. I do not understand your JS and i cannot do it.

This is clearly not my JS 馃槃

But I think it could be a good suggestion to highlight active filter. This could lead to a new feature-request.

Was this page helpful?
0 / 5 - 0 ratings