Skip to content

Commit

Permalink
add detail error to main model
Browse files Browse the repository at this point in the history
mdmunir committed Feb 11, 2016
1 parent 9523138 commit 48da802
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions RelationBehavior.php
Original file line number Diff line number Diff line change
@@ -271,7 +271,8 @@ public function afterValidate()
call_user_func($this->beforeRValidate, $child, $index, $name);
}
if (!$child->validate()) {
$this->_relatedErrors[$name][$index] = $child->getFirstErrors();
$errors = $this->_relatedErrors[$name][$index] = $child->getFirstErrors();
$this->addError($name, "{$index}: ".reset($errors));
$error = true;
}
}
@@ -280,7 +281,8 @@ public function afterValidate()
call_user_func($this->beforeRValidate, $children, null, $name);
}
if (!$children->validate()) {
$this->_relatedErrors[$name] = $child->getFirstErrors();
$errors = $this->_relatedErrors[$name] = $child->getFirstErrors();
$this->addError($name, reset($errors));
$error = true;
}
}
7 changes: 5 additions & 2 deletions RelationTrait.php
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ public function getRelatedErrors()
{
return $this->_relatedErrors;
}

/**
* Populate relation
* @param string $name
@@ -188,7 +189,8 @@ protected function doAfterValidate()
$this->beforeRValidate($child, $index, $name);
}
if (!$child->validate()) {
$this->_relatedErrors[$name][$index] = $child->getFirstErrors();
$errors = $this->_relatedErrors[$name][$index] = $child->getFirstErrors();
$this->addError($name, "{$index}: ".reset($errors));
$error = true;
}
}
@@ -197,7 +199,8 @@ protected function doAfterValidate()
$this->beforeRValidate($children, null, $name);
}
if (!$children->validate()) {
$this->_relatedErrors[$name] = $child->getFirstErrors();
$errors = $this->_relatedErrors[$name] = $child->getFirstErrors();
$this->addError($name, reset($errors));
$error = true;
}
}

0 comments on commit 48da802

Please sign in to comment.