I am trying to put a UNIQUE and COMPARE validator in a same form.
As told, UNIQUE must be “CUniqueValidator can only be used for active record objects.”. That’s fine. so I used CDbActiveRecord.
Then I have another two textfields: password and confirmPassword. I set the rules like
array(‘password’,‘compare’,‘compareAttribute’=>‘confirmPassword’,‘message’=>‘The passwords you typed are different’),
And because in the database table there is no such field as “confirmPassword” but only “password”. So the code returns error like testForm.confirmPassword is not defined…
Seems in CDbActiveRecord, it’s not possible to use unexisted attributes? So how can I use this compare function in CDbActiveRecord instead of adding another field called confirmPassword in Database table ?(or using CFormModel instead of CDbActiveRecord then Unique would be a problem)