Yii form validations: comparing password with a field that does not exists in DB
I am new to Yii framework. I want to validate a password field with the repeated value. I use the following rule:
array('password', 'compare', 'compa开发者_如何转开发reAttribute'=>'password2', 'on'=>'register'),
But I receive this error:
Property "Users.password2" is not defined
How can I fix this problem without creating redundant field password2 in the DB?
You can create the property in the model without creating it in the db, so add it like so:
class Users extends CActiveRecord
{
public $password2;
...
精彩评论