n00b
n00b

Reputation: 16536

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?

Upvotes: 3

Views: 2498

Answers (2)

Kemo
Kemo

Reputation: 7042

$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

Upvotes: 4

n00b
n00b

Reputation: 16536

Ah got it...

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

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

Upvotes: 1

Related Questions