Skip to content

Instantly share code, notes, and snippets.

@awartoft
Created July 9, 2012 12:34
Show Gist options
  • Save awartoft/3076215 to your computer and use it in GitHub Desktop.
Save awartoft/3076215 to your computer and use it in GitHub Desktop.
<?php
/**
* @author Antoine Hedgecock <[email protected]>
*/
/**
* @namespace
*/
namespace Article\Controller\Admin;
use Zend\View\Model\ViewModel,
Zend\Mvc\Controller\AbstractActionController;
class IndexController extends AbstractActionController
{
/**
* @return \Article\Service\Article
*/
protected function getService()
{
return $this->getServiceLocator()
->get('article_service');
}
public function createAction()
{
$vm = new ViewModel();
$vm->setTemplate('article/admin/create');
$form = $this->getServiceLocator()
->get('article_form_admin_create');
$obj = new \Article\Entity\Article();
$form->bind($obj);
if ($this->getRequest()->isPost()) {
//Set the form data..
$form->setData($_POST);
if ($form->isValid()) {
var_dump($obj);
} else {
var_dump($form);
}
}
return $vm->setVariable('form', $form);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment