How to disable render view in zend framework 2?

前端 未结 6 612
臣服心动
臣服心动 2021-01-30 09:39

I want to use some ajax, but I don\'t know how to use function as the same as setNoRender() in zend framework 2 to disable for render view.

How to disable rendering v

6条回答
  •  盖世英雄少女心
    2021-01-30 10:16

    • To disable your view :

      public function myactionAction()
      {
          // your code here ...
          return false;
      }
      

    "return false" disables the view and not the layout! why? because the accepted types are:

    • ViewModel
    • array
    • null

    so "false" disable the view.

    • To disable layout and view, return a response object:

      public function myactionAction()
      {
          // your code here ...
          return $this->response;
      }
      
    • To disable layout:

      public function myactionAction()
      {
          // your code here ...
          $view = new ViewModel();
          $view->setTerminal(true);
          return $view;
      }
      

提交回复
热议问题