Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created November 2, 2011 23:17
Show Gist options
  • Save eminetto/1335264 to your computer and use it in GitHub Desktop.
Save eminetto/1335264 to your computer and use it in GitHub Desktop.
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;
}
@pyTonyc
Copy link

pyTonyc commented Jul 17, 2012

Não compreendi porque foi apresentado o erro "Call to a member function setLabel() on a non-object" na linha 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment