php - the function on Model doesn't work well -
i wanna ask validation on yii. i've put validation on model :
public function cekdigit($attribute,$params) { $subject=substr($attribute,0,2); $pattern=$this->string2; if ($subject!==$pattern) { $this->adderror($attribute, $params['message']); return false; } }
while ran that, turned on error message, condition true. meant, when put same string (which matched) still got error. how can fix becomes valid condition?
thanks
instead of if ($subject!==$pattern)
you might want use if (strcmp($subject,$pattern) == 0)
Comments
Post a Comment