EllisLab text mark
Advanced Search
     
Form validation
Posted: 08 October 2012 01:30 PM   [ Ignore ]
Joined: 2012-08-19
14 posts

Hi guys, so I have a validation function like this:

$config = array(
                 
'question' => array(
                                    array(
                                            
'field' => 'question',
                                            
'label' => 'question',
                                            
'rules' => 'required'
                                         
)),
                
'category' => array(
                                    array(
                                            
'field' => 'category',
                                            
'label' => 'category',
                                            
'rules' => ''
                                         
)));
        if(
$this -> form_validation -> run() == TRUE){
            
return 1;
        
}
        
elseif($this -> form_validation -> run('question') == FALSE && $this -> form_validation -> run('category') == FALSE )
            
return 2;
        
}
        
elseif($this -> form_validation -> run('question') == FALSE || $this -> form_validation -> run('category') == FALSE ){
            
if($this -> form_validation -> run('question') == FALSE){
                
return 3;
            
}
            else{
                
return 4;
            
}          
        }
        
elseif($this -> form_validation -> run() == FALSE){
            
return 0;     
        

The issue is that when category group of validation rules fail and question group of validation rules doesn’t fail, I get the return of 2. I should get the return 3. What’s wrong?