I'm using cakephp 2.1 and cakedc search plugin.
The thing is I can't glue it together. Also got:
Notice (8): Indirect modification of overloaded property ProjectsController::$paginate has no effect [APP\Controller\ProjectsController.php, line 48]
Followed cakedc tutorial but something's missing! Simple search just won't filter anything.
I want to filter by name field.
On my projects model
public $actsAs = array('Search.Searchable');
var $name = 'Project';
public $filterArgs = array(
array('name' => 'name', 'type' => 'like'),
array('name' => 'filter', 'type' => 'query', 'method' => 'orConditions'),
);
public function orConditions($data = array()) {
$filter = $data['filter'];
$cond = array(
'OR' => array(
$this->alias . '.name LIKE' => '%' . $filter . '%',
//$this->alias . '.body LIKE' => '%' . $filter . '%',
));
return $cond;
}
in my controller:
public $components = array('Search.Prg');
public $presetVars = array(
array('field' => 'name', 'type' => 'value')
);
index function updated to use index.ctp only (no find function)
public function index() {
$this->Prg->commonProcess();
$this->Project->recursive = 0;
// next line causes
// Notice (8): Indirect modification of overloaded property ProjectsController::$paginate has no effect [APP\Controller\ProjectsController.php, line 48]
//$this->paginate['conditions'] = $this->Project->parseCriteria($this->passedArgs);
$this->set('projects', $this->paginate());
}
and added search form to view.ctp
echo $this->Form->create('Project', array('url' => array_merge(array('action' => 'index'), $this->params['pass'])));
echo $this->Form->input('name', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();
I know this must be some obvious error on my part, please bear with me. Can anyone help?
Thanks a lot !