Skip to content

Loading…

Test and quick fix #5847 #5848

Closed
wants to merge 2 commits into from

2 participants

@brotbart

Test and quick fix #5847

brotbart added some commits
@brotbart brotbart Add a failing test for lost messages fb96a8d
@brotbart brotbart Fix collection error messages
by retrieving them directly after validation for each collection item
9990670
@brotbart brotbart closed this
@brotbart brotbart reopened this
@weierophinney weierophinney added this to the 2.2.6 milestone
@weierophinney weierophinney self-assigned this
@weierophinney weierophinney added a commit that closed this pull request
@weierophinney weierophinney Merge branch 'hotfix/5848'
Close #5848
Fixes #5847
ef6d51a
@weierophinney weierophinney added a commit that referenced this pull request
@weierophinney weierophinney Merge branch 'hotfix/5848' into develop
Forward port #5848
22b26ba
@weierophinney weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request
@weierophinney weierophinney Merge pull request zendframework/zf2#5848 from brotbart/5847
Test and quick fix zendframework/zf2#5847
aa76a92
@weierophinney weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request
@weierophinney weierophinney Merge branch 'hotfix/5848' into develop fe1d07e
@weierophinney weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request
@weierophinney weierophinney Merge branch 'hotfix/5848' c706702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2014
  1. @brotbart
  2. @brotbart

    Fix collection error messages

    brotbart committed
    by retrieving them directly after validation for each collection item
This page is out of date. Refresh to see the latest.
View
22 library/Zend/InputFilter/CollectionInputFilter.php
@@ -48,6 +48,11 @@ class CollectionInputFilter extends InputFilter
*/
protected $collectionRawValues = array();
+ /*
+ * @var array
+ */
+ protected $collectionMessages = array();
+
/**
* @var BaseInputFilter
*/
@@ -183,6 +188,7 @@ public function isValid()
$values = array();
$rawValues = array();
+ $messages = array();
foreach ($inputs as $name) {
$input = $this->inputs[$name];
@@ -193,9 +199,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;
@@ -259,12 +273,6 @@ public function getRawValues()
*/
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;
}
}
View
3 tests/ZendTest/InputFilter/CollectionInputFilterTest.php
@@ -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()
Something went wrong with that request. Please try again.