问题
At 2.0, I use requestAction
like this:
<?=$this->Form->input('list',array('options'=>$this->requestAction(……)?>
But At 3.0, I use requestAction
nothing display. I don't know how to write options data source.
回答1:
In Cake 3, the results from requestAction must be returned through the response object rather than directly like they were in Cake 2. This is most easily accomplished with JSON encoding.
In the function that you are calling through requestAction:
$options = $table->find(...);
$this->response->body(json_encode($options));
return $this->response;
And then in the view your options parameter would be
'options'=>json_decode($this->requestAction(……), true)
来源:https://stackoverflow.com/questions/30591852/how-to-use-requestaction-in-cakephp-3-0