a question with CUniqueValidator

There’s a AR with listed attributes below:

and I want using CUniqueValidator in rules

public function rules()


    return array(

        array('someName', 'unique', 'criteria' => array(

            'condition' => 'anotherId != :anotherId',

            'params' => array(':anotherId' => $this->anotherId),




but when I look SQL log, I found Yii can’t find $this->anotherId attribute in rules. does anyone has this problem ?

When defining rules you cannot rely on the properties of $this.

If you cannot configure it properly, just create a custom validation rule.

Huh, I call CActiveRecord::validate() after I set each attributes for it, but still can’t got the value, is this a bug?