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 ID value is present in the ID table and ID must have active status . When the user enter the ID i want my validation rule to work (ID EXSIST AND ACTIVE STATUS), 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 isIDTExsist()
{
$record = ID::model()->findAllByAttributes(array('STATUS_NODT'=>'Aktif'),'N0_DT'=>$this->N0_DT);
if($record === null){
$this->addError('error','invalid Nomor DT');
}
}
please help me,
Big Thanks,