Sunday 10 November 2013

How to get model attributes error in Yii Framework

getErrors() Method: It Returns the errors for all attribute or a single attribute.

Reference: http://www.yiiframework.com/doc/api/1.1/CModel#getErrors-detail

Example:
<?php
$valid = $model->validate();
print_r($model->getErrors());
exit;  //To show validation errors

if ($valid) {
    $model->save();
}
?>

No comments:

Post a Comment