sonata-project / SonataDoctrineORMAdminBundle

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

StringFilter IS EMPTY and IS NOT EMPTY #943

Closed bobemoe closed 3 years ago

bobemoe commented 4 years ago

Feature Request

The current StringFilter/ChoiceType allows only allows LIKE, NOT LIKE, and EQUALS:

https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Filter/StringFilter.php

https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Form/Type/Filter/ChoiceType.php

I'm wanting to filter by

I would have a go at implementing this, currently I'm extending the Sonata classes in my own bundle, but wondering if you'd like a PR and if so, have some questions:

  1. It looks like StringFilter and ChoiceType are in different bundles but tightly coupled, would this be 2 PR's or could this be implemented in just one place?
  2. Modify the existing classes so the new functionality is available everywhere, or extend and create a new AdvancedStringFilter (and possibly AdvancedChoiceType) so it needs to be explicitly used.
  3. Starts/Ends with looks simple. But for empty/not empty, there needs to be no value, but the value input field still shows, can I hide that dynamically based on the operator type?
    1. Maybe a different approach is required, Starts/Ends with could be added to StringFilter and the empty/not empty could be a new EmptyFilter based on the Boolean filter which already has no value field.

Though?

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.

peter-gribanov commented 4 years ago

This is a similar issue of https://github.com/sonata-project/SonataAdminBundle/issues/3569

VincentLanglet commented 4 years ago

This is a similar issue of sonata-project/SonataAdminBundle#3569

This issue talk about other filters like StartWith and EndWith. And he's looking for '' value only. This is more precise than your issue.

manu-sparheld commented 4 years ago

Any ideas on how to implement :

This issue talk about other filters like StartWith and EndWith.

TIA

VincentLanglet commented 4 years ago

Any ideas on how to implement :

This issue talk about other filters like StartWith and EndWith.

TIA

Do you want to make a PR ?

StartWith foo = LIKE foo% EndWith foo = LIKE %foo

napestershine commented 4 years ago

@VincentLanglet Please have a look https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1057 https://github.com/sonata-project/SonataAdminBundle/pull/6134

TIA

VincentLanglet commented 3 years ago

There is now a allow_empty option: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1120