Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 741
Tai T Avatar asked Sep 08 '12 17:09

Tai T


1 Answers

  • 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;
    }
    
like image 99
Blanchon Vincent Avatar answered Oct 04 '22 20:10

Blanchon Vincent