Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie
$elements = $fieldset->getElements();
}

if (!$fieldset instanceof Collection || $inputFilter instanceof CollectionInputFilter) {
if (!$fieldset instanceof Collection || !$fieldset->getTargetElement() instanceof FieldsetInterface || $inputFilter instanceof CollectionInputFilter) {
foreach ($elements as $element) {
$name = $element->getName();

Expand Down
57 changes: 57 additions & 0 deletions tests/ZendTest/Form/Element/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,63 @@ public function testCanValidateFormWithCollectionWithoutTemplate()
$this->assertEquals(true, $this->form->isValid());
}

public function testCannotValidateFormWithCollectionWithBadColor()
{
$this->form->setData(array(
'colors' => array(
'#ffffff',
'123465'
),
'fieldsets' => array(
array(
'field' => 'oneValue',
'nested_fieldset' => array(
'anotherField' => 'anotherValue'
)
),
array(
'field' => 'twoValue',
'nested_fieldset' => array(
'anotherField' => 'anotherValue'
)
)
)
));

$this->assertEquals(false, $this->form->isValid());
$messages = $this->form->getMessages();
$this->assertArrayHasKey('colors', $messages);
}

public function testCannotValidateFormWithCollectionWithBadFieldsetField()
{
$this->form->setData(array(
'colors' => array(
'#ffffff',
'#ffffff'
),
'fieldsets' => array(
array(
'field' => 'oneValue',
'nested_fieldset' => array(
'anotherField' => 'anotherValue'
)
),
array(
'field' => 'twoValue',
'nested_fieldset' => array(
'anotherField' => null,
)
)
)
));

$this->assertEquals(false, $this->form->isValid());
$messages = $this->form->getMessages();
$this->assertCount(1, $messages);
$this->assertArrayHasKey('fieldsets', $messages);
}

public function testCanValidateFormWithCollectionWithTemplate()
{
$collection = $this->form->get('colors');
Expand Down