mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-20 10:27:18 +08:00
Fixes #637.
This commit is contained in:
@ -1256,6 +1256,9 @@ class ActiveRecord extends Model
|
||||
$relation = $this->getRelation($name);
|
||||
|
||||
if ($relation->via !== null) {
|
||||
if ($this->getIsNewRecord() || $model->getIsNewRecord()) {
|
||||
throw new InvalidCallException('Unable to link models: both models must NOT be newly created.');
|
||||
}
|
||||
if (is_array($relation->via)) {
|
||||
/** @var $viaRelation ActiveRelation */
|
||||
list($viaName, $viaRelation) = $relation->via;
|
||||
|
Reference in New Issue
Block a user