public function indexAction() { $view = new ViewModel(); $form = $this->serviceLocator->get('Application\\Form\\Company')->init(); $auth = $this->getServiceLocator()->get('zfcuser_auth_service'); $user = $auth->getIdentity(); $user = $this->companyService->setDefaultUserCompany($user); $company = $this->companyService->getCompanyByUser($user); if ($this->request->isPost()) { $form->setData($this->request->getPost()); if ($form->isValid()) { $this->companyService->saveWithParams($company, (array) $form->getData()); $this->companyService->saveCompanyBanks($company, (array) $this->request->getPost()); $translator = $this->serviceLocator->get('MvcTranslator'); $this->flashMessenger()->addMessage($translator->translate('Controller.Company.Edit.CompanySaved')); $this->redirect()->toRoute('application/default', array('controller' => 'company', 'action' => 'index')); } } $banks = $this->companyService->assembleBanksArrayFromCompany($company); $form->setFormValues($company); $view->company = $company; $view->messages = $this->flashMessenger()->getMessages(); $view->user = $user; $view->form = $form; $view->banks = $banks; $view->subject = Company::SUBJECT_COMPANY; return $view; }