Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 218
n00b Avatar asked Jul 16 '26 21:07

n00b


1 Answers

$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

like image 181
Kemo Avatar answered Jul 19 '26 12:07

Kemo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!