EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Have an "autocomplete()" option for EntityFilters , the same as AssociationField::autocomplete

Open allan-simon opened this issue 1 year ago • 2 comments

Short description of what this feature will allow to do:

We have an entity "Company" and an entity "Employee" , and the list of companies start to be quite long , (a dozen thousands)

so when we try to load the filter form to find the employees of a given company , we have a timeout of the renderFilter request

at the opposite for the create form (where there's also a input to choose the company) we fixed the problem by doing

      public function configureFields(string $pageName): iterable
      {
          yield IdField::new('id', 'ID')->hideOnForm();
          yield AssociationField::new('company', 'société')
              // because there are thousands of Company, autoComplete prevents edition page timeout
              // see: https://symfony.com/doc/current/EasyAdminBundle/fields/AssociationField.html#autocomplete
              ->autocomplete()
          ;
      }

so it would be great to have the same possibilities for filters , that would replace the simple html <select> with an autocomplete/ajax one.


      public function configureFilters(Filters $filters): Filters
      {
          return $filters
              ->add('id')
              ->add('company',  'autocomplete') // or  ->add((new EntityFilter('company'))->autocomplete()) ?
          ;
      }

allan-simon avatar Jul 02 '24 15:07 allan-simon