Skip to content

Commit

Permalink
Merge branch 'hotfix/5848' into develop
Browse files Browse the repository at this point in the history
Forward port zendframework#5848
  • Loading branch information
weierophinney committed Mar 3, 2014
2 parents 45b1422 + b119aec commit 22b26ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
22 changes: 15 additions & 7 deletions library/Zend/InputFilter/CollectionInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class CollectionInputFilter extends InputFilter
*/
protected $collectionRawValues = array();

/*
* @var array
*/
protected $collectionMessages = array();

/**
* @var BaseInputFilter
*/
Expand Down Expand Up @@ -188,6 +193,7 @@ public function isValid()

$values = array();
$rawValues = array();
$messages = array();
foreach ($inputs as $name) {
$input = $this->inputs[$name];

Expand All @@ -198,9 +204,17 @@ public function isValid()
}
$values[$name] = $input->getValue($this->data);
$rawValues[$name] = $input->getRawValue();
$tmpMessages = $input->getMessages();
if (!empty($tmpMessages)) {
$messages[$name] = $tmpMessages;
}
}
$this->collectionValues[$key] = $values;
$this->collectionRawValues[$key] = $rawValues;

if (!empty($messages)) {
$this->collectionMessages[$key] = $messages;
}
}

return $valid;
Expand Down Expand Up @@ -284,12 +298,6 @@ public function clearRawValues()
*/
public function getMessages()
{
$messages = array();
foreach ($this->getInvalidInput() as $key => $inputs) {
foreach ($inputs as $name => $input) {
$messages[$key][$name] = $input->getMessages();
}
}
return $messages;
return $this->collectionMessages;
}
}
3 changes: 3 additions & 0 deletions tests/ZendTest/InputFilter/CollectionInputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ public function testGetMessagesForInvalidInputs()
$this->assertCount(2, $messages);
$this->assertArrayHasKey('foo', $messages[0]);
$this->assertArrayHasKey('bar', $messages[1]);

$this->assertCount(1, $messages[0]['foo']);
$this->assertCount(1, $messages[1]['bar']);
}

public function testSetValidationGroupUsingFormStyle()
Expand Down

0 comments on commit 22b26ba

Please sign in to comment.