Skip to content

Commit 6ebb7d9

Browse files
Handle multiple errors in customer address validation when shown in adminhtml customer edit page
1 parent a39e37f commit 6ebb7d9

File tree

1 file changed

+15
-0
lines changed
  • app/code/Magento/Customer/Controller/Adminhtml/Index

1 file changed

+15
-0
lines changed

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
use Magento\Customer\Model\Metadata\Form;
1414
use Magento\Framework\Exception\LocalizedException;
1515

16+
/**
17+
* Class Save
18+
* @package Magento\Customer\Controller\Adminhtml\Index
19+
*
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*/
1622
class Save extends \Magento\Customer\Controller\Adminhtml\Index
1723
{
1824
/**
@@ -268,6 +274,15 @@ public function execute()
268274
$this->_addSessionErrorMessages($messages);
269275
$this->_getSession()->setCustomerFormData($originalRequestData);
270276
$returnToEdit = true;
277+
} catch (\Magento\Framework\Exception\AbstractAggregateException $exception) {
278+
$errors = $exception->getErrors();
279+
$messages = [];
280+
foreach ($errors as $error) {
281+
$messages[] = $error->getMessage();
282+
}
283+
$this->_addSessionErrorMessages($messages);
284+
$this->_getSession()->setCustomerFormData($originalRequestData);
285+
$returnToEdit = true;
271286
} catch (LocalizedException $exception) {
272287
$this->_addSessionErrorMessages($exception->getMessage());
273288
$this->_getSession()->setCustomerFormData($originalRequestData);

0 commit comments

Comments
 (0)