开发者

Kohana 3 - get orm validation errors

if ($user->values($_POST)->check())
{
    $us开发者_运维百科er->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;

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


Ah got it...

if ($user->values($_POST)->check())
{
    $user->save();
} else {

 $errors = $user->validate()->errors();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜