Skip to content

Commit

Permalink
MAGETWO-86545: [Backport 2.3-develop] Handle multiple errors in custo…
Browse files Browse the repository at this point in the history
…mer address validation when shown in adminhtml customer edit page #12937
  • Loading branch information
ishakhsuvarov authored Jan 10, 2018
2 parents e150a7e + 2b02b8b commit 49737ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use Magento\Customer\Model\Metadata\Form;
use Magento\Framework\Exception\LocalizedException;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Save extends \Magento\Customer\Controller\Adminhtml\Index
{
/**
Expand Down Expand Up @@ -268,6 +271,15 @@ public function execute()
$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);
Expand Down

0 comments on commit 49737ed

Please sign in to comment.