diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index f7bea78..e3f9e4f 100644 --- a/src/SaveRelationsBehavior.php +++ b/src/SaveRelationsBehavior.php @@ -371,7 +371,7 @@ private function _prepareHasOneRelation(BaseActiveRecord $model, $relationName, // Save Has one relation new record if ($event->isValid && (count($model->dirtyAttributes) || $model->{$relationName}->isNewRecord)) { Yii::debug('Saving ' . self::prettyRelationName($relationName) . ' relation model', __METHOD__); - if ($model->{$relationName}->save()) { + if ($model->{$relationName}->save(false)) { $this->_savedHasOneModels[] = $model->{$relationName}; } } @@ -462,7 +462,7 @@ protected function _setRelationForeignKeys($relationName) foreach ($relation->link as $relatedAttribute => $modelAttribute) { if ($owner->{$modelAttribute} !== $owner->{$relationName}->{$relatedAttribute}) { if ($owner->{$relationName}->isNewRecord) { - $owner->{$relationName}->save(); + $owner->{$relationName}->save(false); } $owner->{$modelAttribute} = $owner->{$relationName}->{$relatedAttribute}; } @@ -532,7 +532,7 @@ public function _afterSaveHasManyRelation($relationName) if ($relationModel->isNewRecord) { if (!empty($relation->via)) { if ($relationModel->validate()) { - $relationModel->save(); + $relationModel->save(false); } else { $this->_addError($relationModel, $owner, $relationName, self::prettyRelationName($relationName, $i)); throw new DbException('Related record ' . self::prettyRelationName($relationName, $i) . ' could not be saved.'); @@ -545,7 +545,7 @@ public function _afterSaveHasManyRelation($relationName) } if (count($relationModel->dirtyAttributes)) { if ($relationModel->validate()) { - $relationModel->save(); + $relationModel->save(false); } else { $this->_addError($relationModel, $owner, $relationName, self::prettyRelationName($relationName)); throw new DbException('Related record ' . self::prettyRelationName($relationName) . ' could not be saved.'); @@ -655,7 +655,7 @@ private function _afterSaveHasOneRelation($relationName) } } if ($owner->{$relationName} instanceof BaseActiveRecord) { - $owner->{$relationName}->save(); + $owner->{$relationName}->save(false); } } @@ -706,7 +706,7 @@ public function afterDelete() * @param array $data * @throws InvalidConfigException */ - public function loadRelations($data) + public function loadRelationsFromData($data) { /** @var BaseActiveRecord $owner */ $owner = $this->owner; diff --git a/src/SaveRelationsTrait.php b/src/SaveRelationsTrait.php index 8aff2b7..2361853 100644 --- a/src/SaveRelationsTrait.php +++ b/src/SaveRelationsTrait.php @@ -8,9 +8,9 @@ trait SaveRelationsTrait public function load($data, $formName = null) { $loaded = parent::load($data, $formName); - if ($loaded && $this->hasMethod('loadRelations')) { - $this->loadRelations($data); + if ($loaded && $this->hasMethod('loadRelationsFromData')) { + $this->loadRelationsFromData($data); } return $loaded; } -} \ No newline at end of file +}