Welcome Guest, Not a member yet? Register   Sign In
Form validation
#1

[eluser]l1v1[/eluser]
Hi guys, so I have a validation function like this:

Code:
$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?




Theme © iAndrew 2016 - Forum software by © MyBB