我无法在CodeIgniter 3回调中返回错误消息

时间:2017-04-18 23:46:36

标签: php callback codeigniter-3

我是CODEIGNITER的新手,...我无法通过回调发送“verifica_existe_email”函数中的“已在系统中注册的电子邮件”消息。

public function users(){
    init_painel();
    $parametro = get_data_form('acao','get');
    switch ($parametro) {
        case 'cadastrar':
            set_tema('template','painel/usuarios/cadastrar');
            break;
        case 'insert';
            form_validation->set_rules('nome','nome','required');
            $this->form_validation->set_rules('email','email','required|callback_verifica_existe_email');
            $this->form_validation->set_rules('senha','senha','required');
            $this->form_validation->set_rules('re-senha','repita a senha','required|matches[senha]');
            $sucesso = $this->form_validation->run();
            if($sucesso):
            else:
                set_tema('template','painel/usuarios/cadastrar');
            endif;
            break;
        default:
            set_tema('template', 'painel/usuarios/inicio_usuario');
            break;
    }
    load_template();

}

public function verifica_existe_email($email){

    $get_email = $this->usuarios_model->verifica_campo('email_usuario',$email);

    if($get_email):
         $this->form_validation->set_message('verifica_existe_email','Email já cadastrado no sistema');
        return 
    else:
        return FALSE;
    endif;

}

1 个答案:

答案 0 :(得分:0)

由于我不确定,我改变了回报

if ($ get_email):
                 $ This-> form_validation-> set_message ('verifica_existe_email', 'Email already registered in the system');
                  Return TRUE;
                  Else:
                      Return FALSE;
                  Endif;
 for

If ($ get_email)
                 $ This-> form_validation-> set_message ('verifica_existe_email', 'Email already registered in the system');
                  Return FALSE;
                  Else:
                      Return TRUE;
                  Endif;