Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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