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

Commit

Permalink
fix for #3555
Browse files Browse the repository at this point in the history
  • Loading branch information
zluiten committed Jan 24, 2013
1 parent 6627c9b commit f490903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
19 changes: 1 addition & 18 deletions library/Zend/Form/Factory.php
Expand Up @@ -107,7 +107,7 @@ public function create($spec)
$spec = $this->validateSpecification($spec, __METHOD__);
$type = isset($spec['type']) ? $spec['type'] : 'Zend\Form\Element';

$element = $this->getElementFromName($type);
$element = $this->getFormElementManager()->get($type);

if ($element instanceof FormInterface) {
return $this->configureForm($element, $spec);
Expand Down Expand Up @@ -519,23 +519,6 @@ protected function prepareAndInjectValidationGroup($spec, FormInterface $form, $
$form->setValidationGroup($spec);
}

/**
* Try to pull to element from element manager, or instantiates it from its name
*
* @param string $elementName
* @return mixed
*/
protected function getElementFromName($elementName)
{
$formElementManager = $this->getFormElementManager();

if ($formElementManager->has($elementName)) {
return $formElementManager->get($elementName);
}

return new $elementName();
}

/**
* Try to pull hydrator from service manager, or instantiates it from its name
*
Expand Down
7 changes: 7 additions & 0 deletions tests/ZendTest/Form/FactoryTest.php
Expand Up @@ -594,4 +594,11 @@ public function testCanPullHydratorThroughServiceManager()

$this->assertInstanceOf('Zend\Stdlib\Hydrator\ObjectProperty', $fieldset->getHydrator());
}

public function testCreatedFieldsetsHaveFactoryAndFormElementManagerInjected()
{
$fieldset = $this->factory->createFieldset(array('name' => 'myFieldset'));
$this->assertAttributeInstanceOf('Zend\Form\Factory', 'factory', $fieldset);
$this->assertSame($fieldset->getFormFactory()->getFormElementManager(), $this->factory->getFormElementManager());
}
}

0 comments on commit f490903

Please sign in to comment.