Browse files

Merge branch 'hotfix/3735'

Close #3735
  • Loading branch information...
2 parents 40d6ded + 0901c55 commit f9f526b0f72c733e6d221040b8892668dc69c01b @weierophinney weierophinney committed Feb 19, 2013
Showing with 19 additions and 1 deletion.
  1. +1 −1 library/Zend/Form/FormElementManager.php
  2. +18 −0 tests/ZendTest/Form/FormElementManagerTest.php
View
2 library/Zend/Form/FormElementManager.php
@@ -85,7 +85,7 @@ public function __construct(ConfigInterface $configuration = null)
public function injectFactory($element)
{
if ($element instanceof FormFactoryAwareInterface) {
- $element->setFormFactory(new Factory($this));
+ $element->getFormFactory()->setFormElementManager($this);
}
}
View
18 tests/ZendTest/Form/FormElementManagerTest.php
@@ -11,6 +11,8 @@
namespace ZendTest\Form;
use Zend\ServiceManager\ServiceManager;
+use Zend\Form\Factory;
+use Zend\Form\Form;
use Zend\Form\FormElementManager;
/**
@@ -37,6 +39,22 @@ public function testInjectToFormFactoryAware()
$this->assertSame($this->manager, $form->getFormFactory()->getFormElementManager());
}
+ /**
+ * @group 3735
+ */
+ public function testInjectsFormElementManagerToFormComposedByFormFactoryAwareElement()
+ {
+ $factory = new Factory();
+ $this->manager->setFactory('my-form', function ($elements) use ($factory) {
+ $form = new Form();
+ $form->setFormFactory($factory);
+ return $form;
+ });
+ $form = $this->manager->get('my-Form');
+ $this->assertSame($factory, $form->getFormFactory());
+ $this->assertSame($this->manager, $form->getFormFactory()->getFormElementManager());
+ }
+
public function testRegisteringInvalidElementRaisesException()
{
$this->setExpectedException('Zend\Form\Exception\InvalidElementException');

0 comments on commit f9f526b

Please sign in to comment.