public function editAction() { $polling_id = $this->_getParam('id'); $polling = $this->tbl_polling->find($polling_id)->current(); $pollingAnswers = $this->tbl_answer->getAnswersName($polling_id); if (empty($polling)) { $this->_helper->redirector('index'); } $this->form->populate($polling->toArray()); $this->form->answerSubForm->populate($pollingAnswers); if ($this->getRequest()->isPost()) { $polling = $this->getRequest()->getPost('polling'); if ($this->form->isValid($polling)) { if ($polling['showstatus'] == 1) { $this->tbl_polling->update(array('showstatus' => 0), ''); } $this->tbl_polling->update(array('question' => $polling['question'], 'showstatus' => $polling['showstatus']), "polling_id = {$polling_id}"); $this->tbl_answer->delete("polling_id = {$polling_id}"); foreach ($polling['answer'] as $key => $answer) { $data = array('polling_id' => $polling_id, 'answer' => $answer); $this->tbl_answer->insert($data); } $this->_helper->redirector('index'); } } $this->view->form = $this->form; }