0

I am using CakePHP 3.1 and whenever I make use of requestAction, the page goes blank while I get an error in the console. The basic code is:-

$test = $this->requestAction('/dockets/find'.$articleList->id, [], ['return']);

While the dummy controller method is:-

function find($docket_id)
{
      return 0;
}

Whenever I include the code in any view file (.ctp file), I get a blank page. I also get a console error saying the current url cannot be found. The url works fine if I don't include the above code.

drmonkeyninja
  • 8,490
  • 4
  • 31
  • 59
Fahad Sadiq
  • 77
  • 2
  • 11
  • 4
    Take a closer look at the argument that you are passing, the path is lacking a separator after `find`. – ndm Jan 19 '16 at 09:48

1 Answers1

0

Your first argument for requestAction is wrong, there is a missing / after find. It should be:-

$test = $this->requestAction('/dockets/find/' . $articleList->id, [], ['return']);

Alternatively, you could call requestAction using a router array:-

$test = $this->requestAction(
    [
        'controller' => 'dockets', 
        'action' => 'find', 
        $articleList->id
    ], 
    [], 
    ['return']
);
drmonkeyninja
  • 8,490
  • 4
  • 31
  • 59
  • I did it just as you mentioned here but the result is the same. – Fahad Sadiq Jan 20 '16 at 08:01
  • What does your Cake error logs say? Make sure you have `debug` on and perhaps try sending a message to the log in your `find()` method (*e.g.* `$this->log('find() method hit');`) to make sure the method is being triggered. – drmonkeyninja Jan 20 '16 at 08:04