From 50ec6369236bf4c0e502ddb82bec1ddd89bda608 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 2 Sep 2022 21:36:08 +0200 Subject: [PATCH] #313 Handling of link models --- library/Opus/Model/AbstractModel.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Opus/Model/AbstractModel.php b/library/Opus/Model/AbstractModel.php index 8b715ebc..82bdfae2 100644 --- a/library/Opus/Model/AbstractModel.php +++ b/library/Opus/Model/AbstractModel.php @@ -440,10 +440,15 @@ public function updateFromArray($data) if ($linkModelClass !== null) { $linkModel = new $linkModelClass(); $linkModel->setModel($model); + $newModel = $model->isNewRecord(); $model = $linkModel; + if ($newModel) { + // only populate model if it is new + // TODO allow update of dependent models like licences? + $model->updateFromArray($modelValues); + } } - // $model->updateFromArray($modelValues); $models[] = $model; }