Browse Source

Fix for issue #23

tags/1.7.1
Alban Jubert 6 years ago
parent
commit
1fe4827be0
  1. 10
      src/SaveRelationsBehavior.php

10
src/SaveRelationsBehavior.php

@ -288,6 +288,10 @@ class SaveRelationsBehavior extends Behavior
} }
if (($relationModel instanceof BaseActiveRecord) && is_array($data)) { if (($relationModel instanceof BaseActiveRecord) && is_array($data)) {
$relationModel->setAttributes($data); $relationModel->setAttributes($data);
if ($relationModel->hasMethod('loadRelations')) {
$relationModel->loadRelations($data);
}
} }
return $relationModel; return $relationModel;
} }
@ -738,7 +742,7 @@ class SaveRelationsBehavior extends Behavior
} }
/** /**
* @param $relationName * @param $relationName string
* @return mixed * @return mixed
* @throws InvalidConfigException * @throws InvalidConfigException
*/ */
@ -779,7 +783,7 @@ class SaveRelationsBehavior extends Behavior
/** /**
* Returns the old value of the named relation. * Returns the old value of the named relation.
* @param $relationName The relations name as defined in the behavior `relations` parameter * @param $relationName string The relations name as defined in the behavior `relations` parameter
* @return mixed * @return mixed
*/ */
public function getOldRelation($relationName) public function getOldRelation($relationName)
@ -804,7 +808,7 @@ class SaveRelationsBehavior extends Behavior
/** /**
* Mark a relation as dirty * Mark a relation as dirty
* @param $relationName * @param $relationName string
* @return bool Whether the operation succeeded. * @return bool Whether the operation succeeded.
*/ */
public function markRelationDirty($relationName) public function markRelationDirty($relationName)

Loading…
Cancel
Save