我使用插件 cakedc 搜索,但我似乎找不到一件事,我有一个包含两个字段的表单,我会在控制器中的搜索中添加例如“online = 1”,我尝试:
public function find() {
$this->Prg->commonProcess();
$array = array('type'=>'post', 'online'=>'1', 'created'=> '<= NOW()');
$this->passedArgs = Set::merge($this->passedArgs, $array);
$this->paginate = array(
'conditions' => array($this->Post->parseCriteria($this->passedArgs)),
);
$this->set('posts', $this->paginate());
模型:
public $displayField = array('name', 'category_id');
public $filterArgs = array(
array('name' => 'name', 'type' => 'query', 'method' => 'filterName'),
array('name' => 'category_id', 'type' => 'value')
);
.....
调试($this->passedArgs):
array(
'name' => 'mon',
'category_id' => '2',
'type' => 'post',
'online' => '1',
'created' => '<= NOW()'
)
但是我的搜索中没有使用 $array 参数有人可以帮忙吗?我是cakephp的初学者,非常感谢!