Welcome Guest, Not a member yet? Register   Sign In
Validation doesn't work
#3

[eluser]dlange[/eluser]
Hi,

I'm using the 1.7 version but also tested it with the 1.7.1 version which doesn't help either ... I use the form_validation class.

These are the relevant functions in the controller:
Code:
function addUser(){
        $this->auth->check(1);
        $usergroup = $this->auth->getUsergroup();
        $data['template_path'] = $this->config->item('template_path');
        
        /* Rules */
        $this->form_validation->set_rules('anrede', 'Anrede', 'required');
        $this->form_validation->set_rules('firstname', 'Vorname', 'required');
        $this->form_validation->set_rules('name', 'Nachname', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
        $this->form_validation->set_rules('phone', 'Telefon', 'required');
        $this->form_validation->set_rules('admin', 'Admin', 'required|exact_length[1]|is_natural');
        $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|callback__username_check');
    
        /* Load Form */            
        if ($this->form_validation->run() == FALSE):
            $output['content'] = $this->parser->parse('user/adduser.php', $data, TRUE);
            $this->load->view('template.php', $output);
        else:
            /* Save Form */
            /* ... */
            /* ... */
            /* Redirect to Userlist */
            redirect('user/listUsers');        
        endif;

    }
    function _username_check($str)
    {
        $users = $this->db->query('SELECT * FROM users WHERE username='.$this->db->escape($str));
        $count = $users->num_rows();
        if ($count > 0):
            $this->form_validation->set_message('_username_check', 'Username is not available');
            return FALSE;
        else:
            return TRUE;
        endif;
    }


Messages In This Thread
Validation doesn't work - by El Forum - 03-25-2009, 02:14 PM
Validation doesn't work - by El Forum - 03-25-2009, 05:55 PM
Validation doesn't work - by El Forum - 03-26-2009, 07:10 AM
Validation doesn't work - by El Forum - 03-26-2009, 03:14 PM
Validation doesn't work - by El Forum - 03-26-2009, 05:42 PM
Validation doesn't work - by El Forum - 03-26-2009, 06:02 PM
Validation doesn't work - by El Forum - 03-27-2009, 07:10 AM
Validation doesn't work - by El Forum - 03-27-2009, 07:14 AM
Validation doesn't work - by El Forum - 03-27-2009, 07:38 AM
Validation doesn't work - by El Forum - 03-27-2009, 07:42 AM
Validation doesn't work - by El Forum - 03-27-2009, 07:46 AM
Validation doesn't work - by El Forum - 03-27-2009, 07:56 AM
Validation doesn't work - by El Forum - 03-27-2009, 08:21 AM
Validation doesn't work - by El Forum - 03-27-2009, 09:52 AM
Validation doesn't work - by El Forum - 03-27-2009, 11:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB