From d3c369e3420f9c465de72bd34f07bcdbda490f30 Mon Sep 17 00:00:00 2001 From: Alban Jubert Date: Sat, 28 Oct 2017 12:24:28 +0200 Subject: [PATCH] Merge #19 --- src/SaveRelationsBehavior.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index 5e7b1b5..d04cf1f 100644 --- a/src/SaveRelationsBehavior.php +++ b/src/SaveRelationsBehavior.php @@ -8,7 +8,6 @@ use yii\base\Behavior; use yii\base\Exception; use yii\base\ModelEvent; use yii\base\UnknownPropertyException; -use yii\db\ActiveQueryInterface; use yii\db\BaseActiveRecord; use Yii\db\Exception as DbException; use yii\db\Transaction; @@ -86,8 +85,7 @@ class SaveRelationsBehavior extends Behavior */ public function canSetProperty($name, $checkVars = true) { - $getter = 'get' . $name; - if (in_array($name, $this->_relations) && method_exists($this->owner, $getter) && $this->owner->$getter() instanceof ActiveQueryInterface) { + if (in_array($name, $this->_relations) && $this->owner->getRelation($name, false)) { return true; } return parent::canSetProperty($name, $checkVars);