I am building a yii application. Heres the code -:
$id = 2;
$model = Page::model()->findByPk(2);
$model->title = 'HeyMan';
if($model->validate())
{
echo 'Validation retuned true';
}
else
{
$array = $model->getErrors();
$message = 'Validation returned false';
}
And the result is that the validate() returns false while getErrors() returns an empty array. Whats the problem here ? Thanks
Did you use the beforeSave function in your model? Then make sure to return the parent beforeSave:
return parent::beforeSave();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With