phpcakephpcakephp-2.0

cakephp passedArgs empty


I have a simple form in a a view and I am trying to access the $this=>passedArgs but it is coming back empty.

I am actualy trying to use the cakeDC search plugin which uses the $this=>passedArgs. It must be something simple I have not done to get the results from the form submit.

find view

<?php
echo $this->Form->create('Member', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));
echo $this->Form->input('name', array('div' => false));
echo $this->Form->submit(__('Search'), array('div' => false));
echo $this->Form->end();
?>

Controller

public function find() {
    debug($this->passedArgs);
    exit;
}

I have tried $this->request->params

array(
 'plugin' => null,
 'controller' => 'members',
 'action' => 'find',
 'named' => array(),
 'pass' => array(),
 'isAjax' => false
)

I have add method get to the form. This question has been asked before but their solution of having lower cases in the public $uses = array('order', 'product'); when it should be public $uses = array('Order', 'Product'); did not work.

Cakephp version 2.3.5

Thanks for any help

Update:

I have set my form to method get and this is the url:

http://localhost/loyalty/members/find?name=searchtext

I have removed the plugin and I still do not get anything $this->passedArgs, but I now get data for $this->request->data['name']. Once I put public $components = array('Search.Prg'); I get noting again for $this->request->data['name'].

I have tried again $this->Prg->parsedParams() with the Search plugin and I just get array()


Solution

  • The documentation is pretty clear on that. You cannot just debug something that has not been set yet. So including the plugin itself (and its component) is not enough.

    From the readme/documenation:

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->ModelName->parseCriteria($this->passedArgs);
        $this->set('...', $this->paginate());
    }
    

    Note the commonProcess() call which then only makes passedArgs contain what you need.