0
votes

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

1
are you using the current dev branch? there have currently been some fixes regarding this. AND - take a look at the readme - it is now adviced to not use passedArgs anymore if possible.mark
sorry, where can I get the dev branch, I do not see it on githun, is it labeled as something else?Keith Power
just change it with a single click from master to develop - github.com/cakedc/search/tree/developmark
ah ok sorry, I miss understood, yes I am using the dev branch of the cakeDC search plugin. I though you were were referring to Cakephp itself :-( Getting tired I think. I have also tried debugging the $this->Prg->parsedParams(), empty alsoKeith Power
What is your exact url after hitting the search button? I bet it is empty (just the index page) - and that is your problem. That you are not searching for anything there. Thus empty passed params.mark

1 Answers

1
votes

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.