Tai T Tai T - 5 months ago 37
Ajax Question

How to disable render view in zend framework 2?

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 view in zend framework 2?

Answer
  • 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;
    }
    
Comments