File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -154,12 +154,12 @@ public function hasError($field) {
154
154
* Get the errors for a given field
155
155
*
156
156
* @param string $field A dot separated path to check errors on.
157
- * @return mixed Either a string or an array of errors. Null
158
- * will be returned when the field path is undefined .
157
+ * @return array An array of errors, an empty array will be returned when the
158
+ * context has no errors .
159
159
*/
160
160
public function error ($ field ) {
161
161
if (empty ($ this ->_context ['errors ' ])) {
162
- return null ;
162
+ return [] ;
163
163
}
164
164
return Hash::get ($ this ->_context ['errors ' ], $ field );
165
165
}
Original file line number Diff line number Diff line change @@ -301,19 +301,17 @@ public function hasError($field) {
301
301
return !empty ($ errors );
302
302
}
303
303
304
-
305
304
/**
306
305
* Get the errors for a given field
307
306
*
308
307
* @param string $field A dot separated path to check errors on.
309
- * @return array|null Either an array of errors. Null will be returned when the
310
- * field path is undefined or there is no error.
308
+ * @return array An array of errors.
311
309
*/
312
310
public function error ($ field ) {
313
311
$ parts = explode ('. ' , $ field );
314
312
list ($ entity , $ prop ) = $ this ->_getEntity ($ parts );
315
313
if (!$ entity ) {
316
- return false ;
314
+ return [] ;
317
315
}
318
316
return $ entity ->errors (array_pop ($ parts ));
319
317
}
Original file line number Diff line number Diff line change @@ -153,6 +153,9 @@ public function testAttributes() {
153
153
* @return void
154
154
*/
155
155
public function testError () {
156
+ $ context = new ArrayContext ($ this ->request , []);
157
+ $ this ->assertEquals ([], $ context ->error ('Comments.empty ' ));
158
+
156
159
$ context = new ArrayContext ($ this ->request , [
157
160
'errors ' => [
158
161
'Comments ' => [
You can’t perform that action at this time.
0 commit comments