Skip to content

Commit f90b3ab

Browse files
committed
MAGETWO-48286: "Create/Edit Customer" Admin forms do not support data validation without refreshing
1 parent 280e520 commit f90b3ab

File tree

8 files changed

+17
-2
lines changed

8 files changed

+17
-2
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Block/Index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function execute()
3737
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
3838
$resultPage = $this->resultPageFactory->create();
3939
$this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Blocks'));
40+
41+
$dataPersistor = $this->_objectManager->get('Magento\Framework\App\Request\DataPersistorInterface');
42+
$dataPersistor->clear('cms_block');
43+
4044
return $resultPage;
4145
}
4246
}

app/code/Magento/Cms/Controller/Adminhtml/Page/Index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public function execute()
4949
$resultPage->addBreadcrumb(__('Manage Pages'), __('Manage Pages'));
5050
$resultPage->getConfig()->getTitle()->prepend(__('Pages'));
5151

52+
$dataPersistor = $this->_objectManager->get('Magento\Framework\App\Request\DataPersistorInterface');
53+
$dataPersistor->clear('cms_page');
54+
5255
return $resultPage;
5356
}
5457
}

app/code/Magento/Cms/Model/Block/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getData()
7474
$block = $this->collection->getNewEmptyItem();
7575
$block->setData($data);
7676
$this->loadedData[$block->getId()] = $block->getData();
77+
$this->dataPersistor->clear('cms_block');
7778
}
7879

7980
return $this->loadedData;

app/code/Magento/Cms/Model/Page/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function getData()
7272
$page = $this->collection->getNewEmptyItem();
7373
$page->setData($data);
7474
$this->loadedData[$page->getId()] = $page->getData();
75+
$this->dataPersistor->clear('cms_page');
7576
}
7677

7778
return $this->loadedData;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function execute()
3333
$resultPage->addBreadcrumb(__('Manage Customers'), __('Manage Customers'));
3434

3535
$this->_getSession()->unsCustomerData();
36+
$this->_getSession()->unsCustomerFormData();
3637

3738
return $resultPage;
3839
}

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public function getData()
160160
if (!empty($data)) {
161161
$customerId = isset($data['customer']['entity_id']) ? $data['customer']['entity_id'] : null;
162162
$this->loadedData[$customerId] = $data;
163+
$this->getSession()->unsCustomerFormData();
163164
}
164165

165166
return $this->loadedData;

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function setUp()
8686
->getMock();
8787
$this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session')
8888
->disableOriginalConstructor()
89-
->setMethods(['unsCustomerData'])
89+
->setMethods(['unsCustomerData', 'unsCustomerFormData'])
9090
->getMock();
9191

9292
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -137,6 +137,8 @@ public function testExecute()
137137
);
138138
$this->sessionMock->expects($this->once())
139139
->method('unsCustomerData');
140+
$this->sessionMock->expects($this->once())
141+
->method('unsCustomerFormData');
140142

141143
$this->assertInstanceOf(
142144
'Magento\Framework\View\Result\Page',

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function setUp()
6767
->getMock();
6868
$this->sessionMock = $this
6969
->getMockBuilder('Magento\Framework\Session\SessionManagerInterface')
70-
->setMethods(['getCustomerFormData'])
70+
->setMethods(['getCustomerFormData', 'unsCustomerFormData'])
7171
->getMockForAbstractClass();
7272
}
7373

@@ -461,6 +461,8 @@ public function testGetDataWithCustomerFormData()
461461
$this->sessionMock->expects($this->once())
462462
->method('getCustomerFormData')
463463
->willReturn($customerFormData);
464+
$this->sessionMock->expects($this->once())
465+
->method('unsCustomerFormData');
464466

465467
$this->assertEquals([$customerId => $customerFormData], $dataProvider->getData());
466468
}

0 commit comments

Comments
 (0)