Skip to content
Permalink
Browse files

fix for #4563

  • Loading branch information...
antograssiot committed Sep 11, 2014
1 parent d87fcbb commit 828efb090fc24378b3a3e62be6426c9b937fc033
@@ -660,11 +660,12 @@ protected function _readError($object, $path = null) {
return $object->errors($path);
}
if (is_array($object)) {
return array_map(function($val) {
$array = array_map(function($val) {
if ($val instanceof static) {
return $val->errors();
}
}, $object);
return array_filter($array);
}
return [];
}
@@ -456,16 +456,7 @@ public function attributes($field) {
* @return bool Returns true if the errors for the field are not empty.
*/
public function hasError($field) {
$errors = $this->error($field);
if ($errors !== []) {
foreach ($errors as $key => $value) {
if (!is_null($value)) {
return true;
}
}
return false;
}
return false;
return $this->error($field) !== [];
}
/**
@@ -794,13 +794,6 @@ public function testHasError() {
'user' => new Entity(['username' => 'Mark']),
]);
$row->errors('title', []);
$row->errors(['uploadedFile' => [
'name' => null,
'tmp_name' => null,
'error' => null,
'type' => null,
'size' => null
]]);
$row->errors('body', 'Gotta have one');
$row->errors('user_id', ['Required field']);
$context = new EntityContext($this->request, [
@@ -809,7 +802,6 @@ public function testHasError() {
]);
$this->assertFalse($context->hasError('title'));
$this->assertFalse($context->hasError('uploadedFile'));
$this->assertFalse($context->hasError('nope'));
$this->assertTrue($context->hasError('body'));
$this->assertTrue($context->hasError('user_id'));

0 comments on commit 828efb0

Please sign in to comment.
You can’t perform that action at this time.