Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ManyMany Grid Field Search Case Sensitive


Go to End


2 Posts   1321 Views

Avatar
JonShutt

Community Member, 244 Posts

12 June 2013 at 2:55pm

Hi,

on our postres site, the manymany search is defaulting to case sensitive - making it pretty hard to field items.

I've found a way of editing 'GridFieldAddExistingAutocompleter' in the core files to fix this, but is there a away of using somthing like 'setSearchFields' to for case sensititive / case insensitive searches?

$config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('URL','Title'));

Avatar
Sam

Administrator, 690 Posts

12 December 2013 at 1:41pm

Hi,

This has been fixed in 3.1, but if you're using 3.0 you can do this quick patch. Note that this will break other databases, which is why we haven't committed it to 3.0.

--- a/forms/gridfield/GridFieldAddExistingAutocompleter.php
+++ b/forms/gridfield/GridFieldAddExistingAutocompleter.php
@@ -195,7 +195,7 @@ class GridFieldAddExistingAutocompleter
                // TODO Replace with DataList->filterAny() once it correctly supports OR connectives
                $stmts = array();
                foreach($searchFields as $searchField) {
-                       $stmts[] .= sprintf('"%s" LIKE \'%s%%\'', $searchField,
+                       $stmts[] .= sprintf('"%s" ILIKE \'%s%%\'', $searchField,
                                Convert::raw2sql($request->getVar('gridfield_relationsearch')));
                }
                $results = $allList->where(implode(' OR ', $stmts))->subtract($gridField->getList());