Skip to content

Commit

Permalink
Add child error to primary model
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmunir committed Feb 22, 2016
1 parent 48da802 commit 95542f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion RelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 95542f8

Please sign in to comment.