예제 #1
0
 /**
  * 
  */
 public function saveAbstractAction()
 {
     $step = $this->_getParam('step');
     $form = $this->_initForm($step);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $this->_mapper->setData($form->getValues());
             $method = 'save' . ucfirst($step);
             $return = call_user_func(array($this->_mapper, $method));
             $message = $this->_mapper->getMessage()->toArray();
             $result = array('status' => (bool) $return, 'id' => $return, 'description' => $message, 'data' => $form->getValues(), 'fields' => $this->_mapper->getFieldsError());
             $this->_helper->json($result);
         } else {
             $message = new App_Message();
             $message->addMessage($this->_config->messages->warning, App_Message::WARNING);
             $result = array('status' => false, 'description' => $message->toArray(), 'errors' => $form->getMessages());
             $this->_helper->json($result);
         }
     } else {
         $this->_helper->redirector->goToSimple('index');
     }
 }