]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Сохранение информации об ошибке из error_json в error_text
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 24 Dec 2025 07:39:02 +0000 (10:39 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 24 Dec 2025 07:39:02 +0000 (10:39 +0300)
erp24/services/UploadService.php

index 23f4df58ecea2231aa62e7d16f807a14625d370b..c457fb675b04da618f7b7729438f30a34d36bf7d 100644 (file)
@@ -1497,8 +1497,32 @@ class UploadService {
                         if (!empty($arr2["errors"]) && is_array($arr2["errors"])) {
                             $errorDescriptions = [];
                             foreach ($arr2["errors"] as $err) {
-                                if (!empty($err["error_description"])) {
-                                    $errorDescriptions[] = $err["error_description"];
+                                $errorParts = [];
+                                
+                                // Обрабатываем error_json - все элементы массива
+                                if (!empty($err["error_json"]) && is_array($err["error_json"])) {
+                                    foreach ($err["error_json"] as $errorJson) {
+                                        if (!empty($errorJson["field"]) && !empty($errorJson["error"])) {
+                                            $errorParts[] = 'Значение поля ' . $errorJson["field"] . ' с ошибкой: ' . $errorJson["error"];
+                                        } elseif (!empty($errorJson["error"])) {
+                                            $errorParts[] = $errorJson["error"];
+                                        }
+                                    }
+                                }
+                                
+                                // Используем error_description как fallback, если нет error_json
+                                if (empty($errorParts) && !empty($err["error_description"])) {
+                                    $errorParts[] = $err["error_description"];
+                                }
+                                
+                                // Добавляем error, если есть и еще ничего не добавлено
+                                if (empty($errorParts) && !empty($err["error"])) {
+                                    $errorParts[] = $err["error"];
+                                }
+                                
+                                // Объединяем части ошибки для текущего элемента
+                                if (!empty($errorParts)) {
+                                    $errorDescriptions[] = implode('; ', $errorParts);
                                 }
                             }
                             $errorText = implode('; ', $errorDescriptions);