Created
November 2, 2011 23:17
-
-
Save eminetto/1335264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function updateAction() | |
{ | |
$form = new Application_Form_Post(); | |
$form->setAction('/post/update'); | |
$form->submit->setLabel('Alterar'); | |
$posts = new Application_Model_Posts(); | |
//tem dados | |
if ($this->_request->isPost()) { | |
//form valido | |
if ($form->isValid($this->_request->getPost())) { | |
$values = $form->getValues(); | |
$posts->update($values, 'id = ' . $values['id']); | |
$this->_redirect('post/retrieve'); | |
}//form invalido | |
else { // Mostra os erros e popula o form com os dados | |
$form->populate($form->getValues()); | |
} | |
} | |
else { //não tem dados | |
$id = $this->_getParam('id'); | |
$post = $posts->fetchRow("id =$id")->toArray(); | |
$form->populate($post); | |
} | |
$this->view->form = $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Não compreendi porque foi apresentado o erro "Call to a member function setLabel() on a non-object" na linha 5.