]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Wed, 28 May 2025 07:23:44 +0000 (10:23 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 28 May 2025 07:23:44 +0000 (10:23 +0300)
erp24/web/js/validate/validateForm.js

index 55ad42d76f6075ff52cde3679f723fe86c1acc63..5b9ed67963aa630dc3bb7326c965338a0806325c 100755 (executable)
@@ -57,17 +57,24 @@ $(".form-validate button").click(function (e) {
 
     function renderErrors(errors) {
         var messages = [];
+
+        if (errors['__common']) {
+            messages = messages.concat(errors['__common']);
+        }
+
         $.each(errors, function (key, value) {
-            messages.push(value);
-            if (key !== '__common') {
-                var field = yiiform.find('[name="' + key + '"]');
-                if (field.length) {
-                    field.closest('.form-group').addClass('has-error');
-                    field.after('<div class="help-block">' + value[0] + '</div>');
-                }
+            if (key === '__common') return;
+
+            messages = messages.concat(value);
+
+            var field = yiiform.find('[name="' + key + '"]');
+            if (field.length) {
+                field.closest('.form-group').addClass('has-error');
+                field.after('<div class="help-block">' + value[0] + '</div>');
             }
         });
-        var strOut2 = messages.flat().join(', <br>');
+
+        var strOut2 = messages.join(', <br>');
         $('.messages').html(strOut2);
     }
-});
+});
\ No newline at end of file