Skip to content

Instantly share code, notes, and snippets.

@EvanDotPro
Created July 11, 2012 13:51
Show Gist options
  • Save EvanDotPro/3090469 to your computer and use it in GitHub Desktop.
Save EvanDotPro/3090469 to your computer and use it in GitHub Desktop.
<?php
public function addAction() {
$form = new \Zebreco\Form\Contact();
if ($this->getRequest()->isPost()) {
$service = $this->getServiceLocator()->get('Zebreco\Service\Contact');
$form->setData($this->getRequest()->getPost());
if ($form->isValid()) {
$contact = $service->create($form->getData());
if ($contact) {
$this->flashMessenger()->addMessage(array('success' => 'Contact was created successfully.'));
return $this->redirect()->toRoute('zebreco/admin/contact', array(
'action' => 'view',
'id' => $contact->getContactid())
);
}
$form->setMessages($service->getErrorMessages());
}
$this->flashMessenger()->addMessage(array('error' => 'Unable to create contact.'));
}
return array('form' => $form);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment