Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3735'
Browse files Browse the repository at this point in the history
Close #3735
  • Loading branch information
weierophinney committed Feb 19, 2013
2 parents 40d6ded + 0901c55 commit f9f526b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Form/FormElementManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/ZendTest/Form/FormElementManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
namespace ZendTest\Form;

use Zend\ServiceManager\ServiceManager;
use Zend\Form\Factory;
use Zend\Form\Form;
use Zend\Form\FormElementManager;

/**
Expand All @@ -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');
Expand Down

0 comments on commit f9f526b

Please sign in to comment.