0
votes

I am trying to implement cakedc search plugin into my cakephp 2 application. I had the plugin working correctly at one point and something else in the application has knocked it off. However I would like to check that I am going about using the search pluging the right way as it could be the method I am using that is causing a conflict or something similar.

The search is only searching for one field which is order_id from the order model within the orders controller.

In my model I have :

    // Search Filters
public $filterArgs = array(
    array('name' => 'order_id', 'type' => 'like')       
);

Within my controller I have:

    public $presetVars = true;  
    public $components = array('Search.Prg', 'RequestHandler');
    public $uses = array('order', 'product');

    public function find () {

        $this->Prg->commonProcess();
        //debug($this->Order->parseCriteria($this->passedArgs));                 
        $this->paginate = array('conditions' => $this->Order->parseCriteria($this->passedArgs));                     

        $this->set('orders', $this->paginate());
}

EDIT this is happening because I am using the $uses variable in my class to define the controller models. Does anyone know how to define the cakedc search model. I have tried search, searchable and searchablebehavior

1
you should mention if you are using the current master branch or the dev branch (which is newer and might work better) - mark
Hi I am using the current master branch. I have just tried this in another controller and it works fine. This controller (orders) also works fine if i explicitly put the arguments into the url. So something is knocking off the arguments being sent from the form. - DevelopingTheWeb
just for the heck of it try the dev branch. if there is any change in behavior. also, for dev try 'order_id' => array('type' => 'like') for $filterArgs - my new dryer syntax. - mark
Hi thanks for the replies however I have narrowed it down to the fact that I was using the $uses to define the models in the controller. I am having trouble defining the search model though. - DevelopingTheWeb
try to stick to conventions. Note the casing: public $uses = array('Order', 'Product');. The first one will be your primary model here. - mark

1 Answers

0
votes

Try to stick to conventions. Note the casing:

public $uses = array('Order', 'Product');. 

Also note: The first one will be your primary model here.