diff --git a/RelationTrait.php b/RelationTrait.php index 4cd6239..4c9a30b 100644 --- a/RelationTrait.php +++ b/RelationTrait.php @@ -190,7 +190,7 @@ protected function doAfterValidate() } if (!$child->validate()) { $errors = $this->_relatedErrors[$name][$index] = $child->getFirstErrors(); - $this->addError($name, "{$index}: ".reset($errors)); + $this->addError($name, "{$index}: " . reset($errors)); $error = true; } } @@ -282,6 +282,9 @@ protected function childIsEqual($model1, $model2, $keys) if (method_exists($this, 'isEqual')) { return $this->isEqual($model1, $model2, $keys); } + if (empty($keys)) { + return false; + } foreach ($keys as $key) { if (ArrayHelper::getValue($model1, $key) != ArrayHelper::getValue($model2, $key)) { return false;