public function addAction() { $form = new \Accounting\Form\Account($this->getServiceLocator()); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { $data = $form->getData(); $account = new Account(); $account->exchangeArray($data); $account->setCreatedById($this->user()->getIdentity()); $account->setCreatedDateTime(DateBase::getCurrentDateTime()); $account->setStatus($account::STATUS_ACTIVE); $accountMapper = $this->getServiceLocator()->get('Accounting\\Model\\AccountMapper'); $accountMapper->save($account); if ($form->get('afterSubmit')->getValue()) { return $this->redirect()->toUrl($form->get('afterSubmit')->getValue()); } } } $this->getViewModel()->setVariable('form', $form); return $this->getViewModel(); }