I just moved from zf1 to zf2 and some simple task are giving me a headache. I have some filters on my form. Filters are being run on form isValid function andafter this function been run, I expected filtered data to be rebind to the form.
I an using zend framework 2.2.7
This is my controller code:
<?php
namespace Test\Controller;
use Test\Entity\Product;
use Test\Form\CreateProduct;
use Zend\Mvc\Controller\AbstractActionController;
class TestController extends AbstractActionController
{
public function indexAction()
{
$form = new CreateProduct();
$product = new Product();
$form->bind($product);
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($request->getPost());
if ($form->isValid()) {
var_dump($product);
}
$form->bind($product); // manual rebind seems to work but look hackish
}
return array(
'form' => $form,
);
}
}