Wednesday, November 20, 2013

yii Custom Function Validation


public function rules()
 {
 array('about_open', 'required'),
 array('about_open', 'my_required'),
}

      public function my_required($attribute_name, $params){
     if($this->about_open==6 && $this->other2==''){
             $this->addError('other2',
                 'Please Pleae fill other field');
     }
     else if($this->about_open==5 && $this->other1==''){
             $this->addError('other1','Please Pleae fill other field');
     }
}


No comments:

Post a Comment