Welcome Guest, Not a member yet? Register   Sign In
Problem when updating the user data form
#1

Hello, I´m new for here. I have a problem when updating the user data form, because when the user wants update his data in the form, input email show the error: "Email is already in use", It ´s logic because he hasn´t changed his email in the form and there is a validation rule "is_unique" for the email. Is there any way that this validation rule, Codeigniter ignore it in the user data form?

This is the file with the validation rules of that update form:

function getEditRules() {
    return array(
        
        array(
            'field' => 'email', 
            'label' => 'email',
            'rules' => 'required|valid_email|max_length[100]|is_unique[user.email]|trim',
            'errors' => array('required' => 'Introduce a %s', 'max_length' => 'The %s can´t exceed 100 characters', 'valid_email' => 'The %s is not valid', 'is_unique' => 'The %s is already in use')
        ),
        array(
            'field' => 'password',
            'label' => 'password',
            'rules' => 'required|min_length[6]|matches[password_confirm]|trim',
            'errors' => array(
                'required' => 'Introduce a %s.', 'min_length' => 'The %s must have at least 6 characters', 'matches'=>'Passwords don´t match
            ),
        ),
        array(
            'field' => 'password_confirm',
            'label' => 'password',
            'rules' => 'required|min_length[6]|trim',
            'errors' => array(
                'required' => 'Introduce a %s.', 'min_length' => 'The %s must have at least 6 characters'
            )
        )
    );
}

Thanks you very much
Reply
#2

@morter,

You will need to either take the unique portion out or create a custom call back function that is able to handle the email during an user account edit/update.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB