From c9c9e70f1a280f820317b84a9b416358f9d59bb3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 21 Nov 2023 19:43:38 +0100 Subject: [PATCH] Tweaks --- doc/crud.rst | 17 +++++++++++++---- src/Config/Option/SearchMode.php | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/crud.rst b/doc/crud.rst index 49e7f84446..325a603c78 100644 --- a/doc/crud.rst +++ b/doc/crud.rst @@ -240,11 +240,20 @@ Search, Order, and Pagination Options ->setSearchFields(null) // call this method to focus the search input automatically when loading the 'index' page ->setAutofocusSearch() - // force to match all the terms (default mode) - // term1 in (field1 or field2) and term2 in (field1 or field2) + + // by default, the search results match all the terms (SearchMode::ALL_TERMS): + // term1 in (field1 or field2) AND term2 in (field1 or field2) + // e.g. if you look for 'lorem ipsum' in [title, description], + // results require matching 'lorem' in either title or description + // (or both) AND 'ipsum' in either title or description (or both) ->setSearchMode(SearchMode::ALL_TERMS) - // match any terms - // term1 in (field1 or field2) or term2 in (field1 or field2) + + // use the SearchMode::ANY_TERMS option to change the search mode to + // match at least one of the terms: + // term1 in (field1 or field2) OR term2 in (field1 or field2) + // e.g. if you look for 'lorem ipsum' in [title, description], + // results will match either 'lorem' in title or description (or both) + // OR 'ipsum' in title or description (or both) ->setSearchMode(SearchMode::ANY_TERMS) ; } diff --git a/src/Config/Option/SearchMode.php b/src/Config/Option/SearchMode.php index 83660d0023..64ff536e89 100644 --- a/src/Config/Option/SearchMode.php +++ b/src/Config/Option/SearchMode.php @@ -2,6 +2,9 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; +/** + * @author Roland Dufour (https://github.com/tasiot) + */ final class SearchMode { public const ANY_TERMS = 'any_terms';