EasyCorp / EasyCorp/EasyAdminBundle

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

Open
#7,776 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
4.3k
Forks
1.1k
Avg merge
8d 2h
Merged PRs (30d)
11

Description

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']);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at AbstractCrudController::configureCrud and trace the existing setSearchFields() behavior, including how default searchable property fields are determined. Check the CRUD configuration and related tests before defining the addSearchField() and addSearchFields() API. Done means an association property can be added without manually copying the default search fields, with coverage for the requested examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.