From 3123818621f3380a60cf2adffed1f58759ec8e4c Mon Sep 17 00:00:00 2001 From: David Windell Date: Wed, 17 Apr 2013 12:34:11 +0100 Subject: [PATCH] Refactor changes to Form --- library/Zend/Form/Element/Collection.php | 13 ------------- library/Zend/Form/Form.php | 8 +++++++- tests/ZendTest/Form/Element/CollectionTest.php | 6 ------ 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/library/Zend/Form/Element/Collection.php b/library/Zend/Form/Element/Collection.php index 4f6d97f7e99..12306208aed 100644 --- a/library/Zend/Form/Element/Collection.php +++ b/library/Zend/Form/Element/Collection.php @@ -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 * diff --git a/library/Zend/Form/Form.php b/library/Zend/Form/Form.php index 23b090ab0b3..c4c75971ad2 100644 --- a/library/Zend/Form/Form.php +++ b/library/Zend/Form/Form.php @@ -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)) { diff --git a/tests/ZendTest/Form/Element/CollectionTest.php b/tests/ZendTest/Form/Element/CollectionTest.php index 21c725fe0ab..6fec4349fa7 100644 --- a/tests/ZendTest/Form/Element/CollectionTest.php +++ b/tests/ZendTest/Form/Element/CollectionTest.php @@ -413,10 +413,4 @@ protected function prepareForExtract($collection) 'obj3' => $obj3, )); } - - public function testGetElementsForFieldsetCollectionReturnsFieldsetElements() - { - $collection = $this->form->get('fieldsets'); - $this->assertCount(1, $collection->getElements()); - } }