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

Commit

Permalink
Refactor changes to Form
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Apr 17, 2013
1 parent 7ee6bf3 commit 3123818
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
13 changes: 0 additions & 13 deletions library/Zend/Form/Element/Collection.php
Expand Up @@ -329,19 +329,6 @@ public function getTargetElement()
return $this->targetElement;
}

/**
* {@inheritdoc}
*
* If the target element is a FieldsetInterface, return it's attached elements
*/
public function getElements()
{
if ($this->getTargetElement() instanceof FieldsetInterface) {
return $this->getTargetElement()->getElements();
}
return parent::getElements();
}

/**
* Get allow add
*
Expand Down
8 changes: 7 additions & 1 deletion library/Zend/Form/Form.php
Expand Up @@ -697,7 +697,13 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie
}
}

foreach ($fieldset->getElements() as $element) {
if ($fieldset instanceof Collection && $fieldset->getTargetElement() instanceof FieldsetInterface) {
$elements = $fieldset->getTargetElement()->getElements();
} else {
$elements = $fieldset->getElements();
}

foreach ($elements as $element) {
$name = $element->getName();

if ($this->preferFormInputFilter && $inputFilter->has($name)) {
Expand Down
6 changes: 0 additions & 6 deletions tests/ZendTest/Form/Element/CollectionTest.php
Expand Up @@ -413,10 +413,4 @@ protected function prepareForExtract($collection)
'obj3' => $obj3,
));
}

public function testGetElementsForFieldsetCollectionReturnsFieldsetElements()
{
$collection = $this->form->get('fieldsets');
$this->assertCount(1, $collection->getElements());
}
}

0 comments on commit 3123818

Please sign in to comment.