0

I use the plugin cakedc search, but there is one thing I can not seem to find, I have a form with two fields, and I would add for example "online = 1" to my search in my controller, I trying:

    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());

model:

    public $displayField = array('name', 'category_id');

    public $filterArgs = array(
                array('name' => 'name', 'type' => 'query', 'method' => 'filterName'),
                array('name' => 'category_id', 'type' => 'value')
           );
.....

debug($this->passedArgs):

array(
    'name' => 'mon',
    'category_id' => '2',
    'type' => 'post',
    'online' => '1',
    'created' => '<= NOW()'
)

but $array argument are not taken in my search Can anyone help? I am a beginner with cakephp, Thanks a lot !

1

1 Answer 1

0

Instead of

'conditions' => array($this->Post->parseCriteria($this->passedArgs)),

try

'conditions' => $this->Post->parseCriteria($this->passedArgs),

I also recommend you to use DebugKit and to add the generated query to your question in the case it is still not working.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.