Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 Validation Problems [SOLVED]
#1

[eluser]PV-Patrick[/eluser]
When processing validation, I am not showing any errors being returned. I am using the "Saving Sets of Validation Rules to a Config File" method and I am unable to show any errors.

The following code is from my Controller. Note that it only contains relevant information and is not the entire controller.
Code:
$this->load->library('form_validation');

if($this->form_validation->run('add_cp_user') == FALSE) {
    print_r($this->form_validation->_field_data);
    print_r($this->form_validation->_config_rules);
    print_r($this->form_validation->_error_array);
}

The 1st and 3rd print_r statements are empty arrays.

The code below is the form_validation.php file.
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config = array(
        'add_cp_user' =>    array(
                                array(
                                    'field'    => 'username',
                                    'label'    => 'account_username',
                                    'rules'    => 'trim|required|htmlspecialchars|min_length[6]|max_length[50]'
                                ),
                                array(
                                    'field'    => 'password',
                                    'label'    => 'account_password',
                                    'rules'    => 'trim|required|htmlspecialchars|min_length[6]|max_length[30]|matches[confirm_password]'
                                ),
                                array(
                                    'field'    => 'confirm_password',
                                    'label'    => 'account_confirm_password',
                                    'rules'    => 'trim|required|htmlspecialchars|min_length[6]|max_length[30]|matches[password]'
                                )
                            )
);

?>

I have tried a few various ways to preform validation with 1.7 and I have replaced my CI system files a couple times as well. I have been at this for hours and would appreciate any help, thank you!
#2

[eluser]sophistry[/eluser]
could this be the problem: http://codeigniter.com/bug_tracker/bug/5504/

seems that a fix is in the SVN.
#3

[eluser]PV-Patrick[/eluser]
I figured it out.... and unfortunately feel like an idiot. I am doing it via ajax callback and wasn't setting the variable I was sending to $_POST so it was not triggering the validation on it. Ugh...




Theme © iAndrew 2016 - Forum software by © MyBB