Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Process the forms
- if (($this->getRequest()->isPost())
- && ($this->getRequest()->isXmlHttpRequest())) {
- // Initiate response
- $status = false;
- $msg = '';
- $zf = null;
- // Test error
- $form->getElement('nobaru')->addError('This is the error message');
- if ($form->isValid($this->getRequest()->getPost())) {
- // Everything is good
- $status = true;
- } else {
- // Get the error messages
- $zf = $form->getMessages();
- }
- // Setup the response
- $result = json_encode(array('status' => $status,
- 'msg' => $msg,
- 'zf' => $zf));
- $this->_helper->viewRenderer->setNoRender();
- $this->_helper->layout()->disableLayout();
- $this->getResponse()->setHeader('Content-Type', 'application/json');
- $this->getResponse()->setBody($result);
- return;
- } else {
- // Populate the form
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement