Yii Framework Forum: Checkbox Validation Doesn't Show Any Message - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Checkbox Validation Doesn't Show Any Message checkbox validation doesn't show any message Rate Topic: -----

#1 User is offline   ferminako 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 27-February 13

Posted 22 May 2013 - 02:33 PM

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!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users