Why the validation of model doesn't work well?

Hi, i have a code just like this




public function CekNip($attribute,$params)

	{

		$cek=substr($this->getAttribute($attribute),0,2);

		$ricek=user::model()->kode_prop;

		if ($cek!==$ricek)

		{

			$this->addError($attribute, $params['message']);

			return false;

		}

		else return true;

	}



But it didn’t work as well whe the condition was true. How can i fix it? Thanks

This is insufficient information for us to help you. Please do some debugging. Print these two:

$cek=substr($this->getAttribute($attribute),0,2);

$ricek=user::model()->kode_prop;

what is kode_prop and where is it defined.

!!!Also please note that you are comparing not only the value but also the type of the data ($cek!==$ricek) try $cek!=$ricek and see if it works that way