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

Commit

Permalink
Updated Zend\Form\Factory, prepareAndInjectElements() continue on nul…
Browse files Browse the repository at this point in the history
…l element specification
  • Loading branch information
bacinsky committed Aug 16, 2013
1 parent 3138073 commit e32b4c7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/Zend/Form/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ protected function prepareAndInjectElements($elements, FieldsetInterface $fields
$elements = $this->validateSpecification($elements, $method);

foreach ($elements as $elementSpecification) {
if (null === $elementSpecification) {
continue;
}

$flags = isset($elementSpecification['flags']) ? $elementSpecification['flags'] : array();
$spec = isset($elementSpecification['spec']) ? $elementSpecification['spec'] : array();

Expand Down
27 changes: 27 additions & 0 deletions tests/ZendTest/Form/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,31 @@ public function testCreatedFieldsetsHaveFactoryAndFormElementManagerInjected()
$this->assertAttributeInstanceOf('Zend\Form\Factory', 'factory', $fieldset);
$this->assertSame($fieldset->getFormFactory()->getFormElementManager(), $this->factory->getFormElementManager());
}

public function testCanCreateFormWithNullElements()
{
$form = $this->factory->createForm(array(
'name' => 'foo',
'elements' => array(
'bar' => array(
'spec' => array(
'name' => 'bar',
),
),
'baz' => null,
'bat' => array(
'spec' => array(
'name' => 'bat',
),
),
),
));
$this->assertInstanceOf('Zend\Form\FormInterface', $form);

$elements = $form->getElements();
$this->assertEquals(2, count($elements));
$this->assertTrue($form->has('bar'));
$this->assertFalse($form->has('baz'));
$this->assertTrue($form->has('bat'));
}
}

0 comments on commit e32b4c7

Please sign in to comment.