Created
July 11, 2012 13:51
-
-
Save EvanDotPro/3090469 to your computer and use it in GitHub Desktop.
This file contains 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
<?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