Skip to content

CRUD Controller feature request: $crud->addSearchField() #7776

Description

@nbpenn

Short description of what this feature will allow to do:
In the AbstractCrudController::configureCrud method, there is a way to pass a set of searchable fields via setSearchFields():

public function configureCrud(Crud $crud): Crud
{
    return $crud
       ...
        ->setSearchFields(['name', 'description', 'seller.email', 'seller.address.zipCode'])
        ...

https://symfony.com/bundles/EasyAdminBundle/current/crud.html#search-order-and-pagination-options

However, if you have an association, you would need to explicitly declare all of the searchable fields, which could be quite a few:

// Manually include default search fields, and an association property field
 $crud->setSearchFields(['name','description',...,...,'association_field.property'];

Example of how to use this feature
It would be nice to be able to simply tack on the association field rather than copy paste all the other fields and then add the other field, something like:

// Include all the default property fields, and the additional association property:
$crud->addSearchField('association_field.property');

and / or

$crud->addSearchFields(['association_field.property']);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions