From 92cdda5ab89482cd8866e42923dc96c4ce72f783 Mon Sep 17 00:00:00 2001 From: pfoldes Date: Wed, 7 Jun 2017 17:16:15 +0300 Subject: [PATCH] Fixed bug when trying to save junction table rows for related models that were not saved before. --- src/SaveRelationsBehavior.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index f1711b4..f0c03b5 100644 --- a/src/SaveRelationsBehavior.php +++ b/src/SaveRelationsBehavior.php @@ -299,7 +299,8 @@ public function afterSave() if ($relation->via !== null) { $relationModel->save(false); } - $model->link($relationName, $relationModel); + $junctionTableColumns = $this->_getJunctionTableColumns($relationName, $relationModel); + $model->link($relationName, $relationModel, $junctionTableColumns); } else { $existingRecords[] = $relationModel; }