diff --git a/src/FhcsFormTest/Controller/IndexController.php b/src/FhcsFormTest/Controller/IndexController.php index cde3495..b834f6f 100644 --- a/src/FhcsFormTest/Controller/IndexController.php +++ b/src/FhcsFormTest/Controller/IndexController.php @@ -26,7 +26,7 @@ public function indexAction() { $freight->addProduct($product). $order->addFreight($freight); - $form = $this->getFormElementManager()->get('FhcsFormTest\Form\SomeForm'); + $form = $this->getFormElementManager()->get('FhcsFormTest\Form\OrderFieldset'); $form->bind($order); return array('form' => $form); diff --git a/src/FhcsFormTest/Form/FreightFieldset.php b/src/FhcsFormTest/Form/FreightFieldset.php index 825cd78..097a8ca 100644 --- a/src/FhcsFormTest/Form/FreightFieldset.php +++ b/src/FhcsFormTest/Form/FreightFieldset.php @@ -7,9 +7,9 @@ use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; class FreightFieldset extends Fieldset { - + protected $entityManager; - + public function getEntityManager() { return $this->entityManager; } @@ -17,10 +17,10 @@ public function getEntityManager() { public function setEntityManager($entityManager) { $this->entityManager = $entityManager; } - + public function init(){ - $this->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'FhcsFormTest\Entity\Freight'))->setObject(new Freight()); - + $this->setHydrator(new DoctrineHydrator($this->getEntityManager())); + $this->add(array( 'type' => 'Zend\Form\Element\Collection', 'name' => 'products', @@ -30,5 +30,6 @@ public function init(){ ) ) )); + $this->get('products')->setHydrator(new DoctrineHydrator($this->getEntityManager())); } } \ No newline at end of file diff --git a/src/FhcsFormTest/Form/OrderFieldset.php b/src/FhcsFormTest/Form/OrderFieldset.php index 0459057..c0c7f6e 100644 --- a/src/FhcsFormTest/Form/OrderFieldset.php +++ b/src/FhcsFormTest/Form/OrderFieldset.php @@ -2,14 +2,14 @@ namespace FhcsFormTest\Form; -use Zend\Form\Fieldset; +use Zend\Form\Form; use FhcsFormTest\Entity\Order; use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; -class OrderFieldset extends Fieldset{ - +class OrderFieldset extends Form{ + protected $entityManager; - + public function getEntityManager() { return $this->entityManager; } @@ -29,5 +29,6 @@ public function init(){ ) ) )); + $this->get('freights')->setHydrator(new DoctrineHydrator($this->getEntityManager())); } } \ No newline at end of file diff --git a/src/FhcsFormTest/Form/ProductFieldset.php b/src/FhcsFormTest/Form/ProductFieldset.php index 9d4f29f..bfced3e 100644 --- a/src/FhcsFormTest/Form/ProductFieldset.php +++ b/src/FhcsFormTest/Form/ProductFieldset.php @@ -20,7 +20,7 @@ public function setEntityManager($entityManager) { public function init() { - $this->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'FhcsFormTest\Entity\Product'))->setObject(new Product()); + $this->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'FhcsFormTest\Entity\Product')); $this->add(array( 'type' => 'text',