How to use $this->autoRender = false in cakephp 3.6.10?

一世执手 提交于 2019-12-11 09:17:09

问题


I am trying to display the test data on the screen by running function test() in the pagesController. Used $this->autoRender = false for it, but it is still giving me error:

Please help me out. I think some version problem is there, but I can't figure it out. Thankyou.


回答1:


Cakephp by default takes Pages controller's display actions as a home page. display function manages pages and subpages itself that is why you are getting error. Either you can change your default home page in your /config/routes.php

 $routes->connect('/', ['controller' => 'Pages', 'action' => 'index']);

OR

define your test action in some other controller.

OR

Remove code from display action

class PagesController {
    function display()
    {
        // default controller code here
        // your custom code here
    }
}

Hope this will work.



来源:https://stackoverflow.com/questions/51838952/how-to-use-this-autorender-false-in-cakephp-3-6-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!