Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow highlight searchable fields with different names #6246

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

zorn-v
Copy link
Contributor

@zorn-v zorn-v commented Apr 7, 2024

Imagine crud controller with following configuration

//...
    public function configureCrud(Crud $crud): Crud
    {
        return $crud
            ->setSearchFields(['child_collection.subentity.title'])
        ;
    }
//...
    public function configureFields(string $pageName): iterable
    {
        return [
            CollectionField::new('child_collection')
        ];
    }

In such case, search works fine by subnested field.
Search query looks like

SELECT * FROM entity 
LEFT JOIN child_collection ON entity.id = child_collection.entity_id 
LEFT JOIN subentity ON child_collection.subentity_id = subentity.id 
WHERE (LOWER(subentity.title) LIKE ?)

BUT, search terms does not highlighted in index page, because searchable css class does not added to td

With proposed change it will be possible to do like this and all will be fine

setSearchFields([
  'child_collection' => 'child_collection.subentity.title',
  'some_other_field',
])

@zorn-v
Copy link
Contributor Author

zorn-v commented Apr 7, 2024

Also it will be possible to highlight "unmapped" field combined from other fields like

setSearchFields([
  'customer.full_name' => 'customer.surname',
  'customer.name',
  'customer.patronymic',
])

@zorn-v
Copy link
Contributor Author

zorn-v commented Apr 7, 2024

Just realized that you can simply manually add searchable css class to field via addCssClass 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant