Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » [Solved] Searchable_fields sort?

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

Page: 1
Go to End
Author Topic: 632 Views
  • Graphicator
    Avatar
    Community Member
    62 Posts

    [Solved] Searchable_fields sort? Link to this post

    Overriding a textfield is pretty basic

       
    static $searchable_fields = array(
          "Title" => array(
              "field" => "TextField",
              "filter" => "PartialMatchFilter",
              "title" => 'Caller Name'
          )

    In Order to override the design of a Dropdown field, I placed

          "Destinations.ID" => array(
              "filter" => "ExactMatchFilter",
              "title" => 'Destination'
          )

    By removing the field in the array.
    Is there a sort that I can place in the array?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: [Solved] Searchable_fields sort? Link to this post

    I don't know (and don't think so) - but would very much like this option too!

    you might be able to hack it by overriding (in your ModelAdmin_CollectionController)

       function getSearchQuery($searchCriteria){
       $query = parent::getSearchQuery($searchCriteria);
       //modify $query here
       return $query;
    }

    alternative is to have the best sort defined in the dataobject...

       static $default_sort = 'Title ASC';

  • Graphicator
    Avatar
    Community Member
    62 Posts

    Re: [Solved] Searchable_fields sort? Link to this post

    Your alternative worked. Thank you!

    632 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.