Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1.  
  2. // Process the forms
  3. if (($this->getRequest()->isPost())
  4.         && ($this->getRequest()->isXmlHttpRequest())) {
  5.  
  6.     // Initiate response
  7.     $status = false;
  8.     $msg = '';
  9.     $zf = null;
  10.    
  11.     // Test error
  12.     $form->getElement('nobaru')->addError('This is the error message');            
  13.  
  14.     if ($form->isValid($this->getRequest()->getPost())) {
  15.    
  16.     // Everything is good
  17.         $status = true;
  18.  
  19.     } else {
  20.  
  21.     // Get the error messages
  22.         $zf = $form->getMessages();
  23.     }
  24.  
  25.     // Setup the response
  26.     $result = json_encode(array('status' => $status,
  27.                                 'msg' => $msg,
  28.                                 'zf' => $zf));
  29.  
  30.     $this->_helper->viewRenderer->setNoRender();
  31.     $this->_helper->layout()->disableLayout();
  32.  
  33.     $this->getResponse()->setHeader('Content-Type', 'application/json');
  34.     $this->getResponse()->setBody($result);
  35.  
  36.     return;
  37.  
  38. } else {
  39.     // Populate the form
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement