From 95542f822433dd7c59b139a1dad4c698c41c30f7 Mon Sep 17 00:00:00 2001 From: mdmunir Date: Mon, 22 Feb 2016 09:51:54 +0700 Subject: [PATCH] Add child error to primary model --- RelationTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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;