From b89d958fed4844bdbfc0213d7b19e12f1b17c487 Mon Sep 17 00:00:00 2001 From: Marcelo Andrade R Date: Tue, 5 Sep 2017 17:08:23 -0500 Subject: [PATCH] TM-1539 - some validations we use array as field name --- src/Result/Adapters/ActiveModel/Result.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Result/Adapters/ActiveModel/Result.php b/src/Result/Adapters/ActiveModel/Result.php index 1090fb9..491e2a9 100755 --- a/src/Result/Adapters/ActiveModel/Result.php +++ b/src/Result/Adapters/ActiveModel/Result.php @@ -94,11 +94,18 @@ protected function formatFailure($result) $errorBlock = []; if ($error->validationList) { foreach ($error->validationList as $validation) { - $field = $inflector->normalize($validation->getField(), $appConfig['propertyFormatTo']); - if (!isset($errorBlock[$field])) { - $errorBlock[$field] = []; + if (is_array($validation->getField())) { + $fields = $validation->getField(); + } else { + $fields = [$validation->getField()]; + } + foreach($fields as $fieldName) { + $field = $inflector->normalize($fieldName, $appConfig['propertyFormatTo']); + if (!isset($errorBlock[$field])) { + $errorBlock[$field] = []; + } + $errorBlock[$field][] = $validation->getMessage(); } - $errorBlock[$field][] = $validation->getMessage(); } }