Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » SS3: Search multiple DataObjects

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 543 Views
  • arnhoe
    Community Member
    6 Posts

    SS3: Search multiple DataObjects Link to this post

    I am using SS3, but I have used the documentation (http://doc.silverstripe.org/framework/en/topics/search). I got it working ofcourse, but I want to use multiple dataobjects, but I dont understand the following sentence.

    In case you need multiple contexts, consider namespacing your request parameters by using FieldList->namespace() on the $fields constructor parameter.

    Is there anyone, who could help me? This my current code.

    public function SearchForm() {
          $context = singleton('CaseItem')->getCustomSearchContext();
          $fields = $context->getSearchFields();
          $form = new Form($this, "SearchForm",
             new FieldList(
                new FormAction('doSearch')
          return $form;

       public function doSearch($data, $form) {
          $context = singleton('CaseItem')->getCustomSearchContext();
          $results = $this->getResults($data);
          return $this->customise(array(
             'Results' => $results
          ))->renderWith(array('Page_results', 'Page'));

       public function getResults($searchCriteria = array()) {
          $start = ($this->request->getVar('start')) ? (int)$this->request->getVar('start') : 0;
          $limit = 10;

          $context = singleton('CaseItem')->getCustomSearchContext();
          $query = $context->getQuery($searchCriteria, null, array('start'=>$start,'limit'=>$limit));
          $records = $context->getResults($searchCriteria, null, array('start'=>$start,'limit'=>$limit));

          if($records) {
             $records = new PaginatedList($records, $this->request);

          return $records;

  • arnhoe
    Community Member
    6 Posts

    Re: SS3: Search multiple DataObjects Link to this post

    Anyone who can help me?

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.