Jump to:

22970 Posts in 11572 Topics by 2823 members

General Questions

SilverStripe Forums » General Questions » ManyMany Grid Field Search Case Sensitive

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

Page: 1
Go to End
Author Topic: 305 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    ManyMany Grid Field Search Case Sensitive Link to this post

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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: ManyMany Grid Field Search Case Sensitive Link to this post

    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());

    305 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.