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.

General Questions /

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

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

ManyMany Grid Field Search Case Sensitive


Reply


2 Posts   451 Views

Avatar
Futureweb

Community Member, 233 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, 685 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());