Fix support for updating belongsTo relationships with the RelationController.

Fixes #5198, #5243; replaces #5217. Related: 6e25c5a8d0#
This commit is contained in:
Luke Towers 2020-08-23 23:57:05 -06:00
parent f708754f07
commit 5a843bc909

View File

@ -1157,7 +1157,11 @@ class RelationController extends ControllerBehavior
}
}
elseif ($this->viewMode == 'single') {
$this->viewModel = $this->manageWidget->model;
// Ensure that the view widget model is the same instance as the manage widget model
// since they will technically be different object instances in this context as
// $viewWidet->model is populated by $this->relationModel->getResults() and
// $manageWidget->model is populated by $this->relationModel->find($manageId);
$this->viewModel = $this->viewWidget->model = $this->manageWidget->model;
$this->viewWidget->setFormValues($saveData);
$this->viewModel->save(null, $this->manageWidget->getSessionKey());