From 6ebb7d945dce12cb21c8b2ae12094e4df9bc4430 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n=20Mart=C3=ADnez?=
 <adrian.martinez@interactiv4.com>
Date: Fri, 29 Dec 2017 14:48:36 +0100
Subject: [PATCH] Handle multiple errors in customer address validation when
 shown in adminhtml customer edit page

---
 .../Customer/Controller/Adminhtml/Index/Save.php  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
index 44eba83d96d..202fe8f69b9 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
@@ -13,6 +13,12 @@ use Magento\Customer\Model\EmailNotificationInterface;
 use Magento\Customer\Model\Metadata\Form;
 use Magento\Framework\Exception\LocalizedException;
 
+/**
+ * Class Save
+ * @package Magento\Customer\Controller\Adminhtml\Index
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
 class Save extends \Magento\Customer\Controller\Adminhtml\Index
 {
     /**
@@ -268,6 +274,15 @@ class Save extends \Magento\Customer\Controller\Adminhtml\Index
                 $this->_addSessionErrorMessages($messages);
                 $this->_getSession()->setCustomerFormData($originalRequestData);
                 $returnToEdit = true;
+            } catch (\Magento\Framework\Exception\AbstractAggregateException $exception) {
+                $errors = $exception->getErrors();
+                $messages = [];
+                foreach ($errors as $error) {
+                    $messages[] = $error->getMessage();
+                }
+                $this->_addSessionErrorMessages($messages);
+                $this->_getSession()->setCustomerFormData($originalRequestData);
+                $returnToEdit = true;
             } catch (LocalizedException $exception) {
                 $this->_addSessionErrorMessages($exception->getMessage());
                 $this->_getSession()->setCustomerFormData($originalRequestData);
-- 
GitLab