Hi everyone, I’ve got a problem… when I do the model validation in a form using this rules:
public function rules(){
return array(
array('...','required','on'=>'motor'),...
All the attributes are validated and if some attributes is empty, I get the error message, but I’ve got also two checkboxes using validation functions:
public function rules(){
return array(
array('...','required','on'=>'motor'),
array('chk1', 'validationChk1','on'=>'motor'),
array('chk2', 'validationChk2','on'=>'motor'),
....
}
public function validationChk1($attribute,$params){
if($this->chk1==0){
$this->adderror('chk1','It should be checked.');
}
}
public function validationChk2($attribute,$params){
if($this->chk2==0){
$this->adderror('chk2','It should be checked.');
}
}
And this functions work, as all my validation functions but the problem is that with these I don’t get the error message telling me that chk1 or 2 or both should be checked…
I’ve tried to put the error message in rules as well but it doesn’t work…
Any idea/solution?
Thanks!