This commit is contained in:
Ben Thomson 2020-08-24 15:23:49 +08:00
parent d104d47911
commit 684d18ffc4
No known key found for this signature in database
GPG Key ID: 8BDB18DD0909BE22
1 changed files with 3 additions and 3 deletions

View File

@ -1125,7 +1125,7 @@ class RelationController extends ControllerBehavior
if ($this->relationType === 'hasOne') {
// Unassign previous relation if one is already assigned
$relation = $this->relationObject->getParent()->{$this->relationName};
$relation = $this->relationObject->getParent()->{$this->relationName} ?? null;
if ($relation) {
$this->relationObject->remove($relation, $sessionKey);
@ -1255,8 +1255,8 @@ class RelationController extends ControllerBehavior
elseif ($this->viewMode == 'single') {
if ($recordId && ($model = $this->relationModel->find($recordId))) {
if ($this->relationType === 'hasOne') {
// Unassign previous relations for singular relation types
$relation = $this->relationObject->getParent()->{$this->relationName};
// Unassign previous relation if one is already assigned
$relation = $this->relationObject->getParent()->{$this->relationName} ?? null;
if ($relation) {
$this->relationObject->remove($relation, $sessionKey);