Model Validation Rule

hi all,

I have a problem in a yii validation rule, I have created a student form with ID and name. When the user enter a ID, I want to check if the value is present in the ID table and value have active status. When the user enter the ID i want my validation rule to work, for student I have a student model (ID, NAME)and for ID I have a ID model(ID, STATUS).

i know it can solve by use dropdownlist, but i do not want to use it. I am using this method in validation rules.

public function rules()

{

array(‘ID’, ‘isIDExsist’),

}

public function isIDExsist(){

$record = ID::model()->findAllByAttributes(array(‘STATUS’=>‘Aktif’),‘ID’=>$this->ID);

   if($record === null){


        $this->addError('error','invalid ID');


        }

}

please help me,

Big Thanks, :D

it should be:

$record = ID::model()->findAllByAttributes(array(‘STATUS’=>‘Aktif’,‘ID’=>$this->ID));

other than that, your validation looks fine