diff --git a/controllers/PasswordController/UpdateAction.php b/controllers/PasswordController/UpdateAction.php index 98bdaa4..d999c46 100644 --- a/controllers/PasswordController/UpdateAction.php +++ b/controllers/PasswordController/UpdateAction.php @@ -47,6 +47,7 @@ protected function _prepare() throw new Maniple_Controller_Exception_NotFound('User was not found'); } + $this->_ajaxFormHtml = $this->getScalarParam('ajaxFormHtml', $this->_ajaxFormHtml); $this->_form = new ManipleUser_Form_Password($this->_passwordService, $user); } @@ -60,17 +61,20 @@ protected function _process() $userManager->saveUser($user); + $successMessage = $this->view->translate('Your password has been changed'); + if ($this->isAjax()) { - $this->view->success = $this->view->translate('Your password has been changed'); - $this->_helper->json(array( - 'data' => array( - 'html' => $this->renderForm() - ), - )); + $this->view->success = $successMessage; + + $ajaxResponse = $this->getAjaxResponse(); + $ajaxResponse->setSuccess($successMessage); + $ajaxResponse->setData($this->_ajaxFormHtml ? $this->renderForm() : null); + $ajaxResponse->sendAndExit(); + return false; } - $this->_helper->flashMessenger->addSuccessMessage($this->view->translate('Your password has been changed')); + $this->_helper->flashMessenger->addSuccessMessage($successMessage); $config = $this->getResource('modules')->offsetGet('maniple-user')->getOptions(); $continue = isset($config['afterLoginRoute'])