farzan
farzan

Reputation: 1170

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', 'compareAttribute'=>'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?

Upvotes: 1

Views: 3901

Answers (1)

ldg
ldg

Reputation: 9402

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;
            ...

Upvotes: 2

Related Questions