-
-
Save tournasdim/9996886 to your computer and use it in GitHub Desktop.
Controller using Form
This file contains hidden or 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 | |
namespace Helloworld\Controller; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use Zend\View\Model\ViewModel; | |
class IndexController extends AbstractActionController | |
{ | |
public function indexAction() | |
{ | |
$form = new \Helloworld\Form\SignUp(); | |
$form->setHydrator(new \Zend\Stdlib\Hydrator\Reflection()); | |
$form->bind(new \Helloworld\Entity\User()); | |
if ($this->getRequest()->isPost()) { | |
$form->setData($this->getRequest()->getPost()); | |
if ($form->isValid()) { | |
var_dump($form->getData()); | |
} else { | |
return new ViewModel( | |
array( | |
'form' => $form | |
) | |
); | |
} | |
} else { | |
return new ViewModel( | |
array( | |
'form' => $form | |
) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment