[英]Kohana 3 - get orm validation errors
if ($user->values($_POST)->check())
{
$user->save();
} else {
// How can i get the errors?
}
Any idea how that works? 知道它是如何工作的吗?
$user->_validate()->errors()
or 要么
$user->validate()->errors()
depending on the version you're using. 取决于您使用的版本。
Or, you can add a method in application/classes/orm.php with this; 或者,您可以在application / classes / orm.php中添加一个方法;
class ORM extends Kohana_ORM {
public function errors($file = 'validate', $translate = TRUE)
{
return $this->_validate->errors( $file, $translate );
}
}
and than call errors with $user->errors() , which I find a lot easier 并且使用$ user-> errors()调用错误,我发现它更容易
Ah got it... 啊明白了......
if ($user->values($_POST)->check())
{
$user->save();
} else {
$errors = $user->validate()->errors();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.