public function editTipoServicoAction() { // action body $form = new Application_Form_TipoServico(); $form->submit->setLabel('Salvar'); //$form->removeElement("tabela_contratacao"); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { Zend_Registry::get('logger')->log($formData, Zend_Log::INFO); $ID_TIPO_SERVICO = (int) $form->getValue('ID_TIPO_SERVICO'); $NM_TIPO_SERVICO = $form->getValue('NM_TIPO_SERVICO'); $tipoServico = new Application_Model_DbTable_TipoServico(); Zend_Registry::get('logger')->log($formData, Zend_Log::INFO); try { $tipoServico->updateTipoServico($ID_TIPO_SERVICO, $NM_TIPO_SERVICO); $this->view->mensagem = "Atualizado com sucesso"; $this->view->erro = 0; //$this->_helper->redirector('lista-usuario'); } catch (Exception $e) { $this->view->mensagem = "Atualizar tipo serviço"; $this->view->erro = 1; $this->view->mensagemExcecao = $e->getMessage(); // echo ($e->getCode()."teste".$e->getMessage() ); } } else { $form->populate($formData); $arrMessages = $form->getMessages(); foreach ($arrMessages as $field => $arrErrors) { $this->view->erro = 1; $this->view->mensagem = $this->view->mensagem . $form->getElement($field)->getLabel() . $this->view->formErrors($arrErrors) . "<br>"; } } } else { $id = $this->_getParam('id', 0); if ($id > 0) { $tipoServico = new Application_Model_DbTable_TipoServico(); Zend_Registry::get('logger')->log("Id contato =" . $id, Zend_Log::INFO); $form->populate($tipoServico->getTipoServico($id)); } } }