Advertisement
Guest User

Untitled

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