永远不会调用Codeigniter form_validation回调

时间:2015-01-11 00:00:45

标签: php codeigniter

我在我的用户模型中设置了表单规则,并且我很难来访问is_unique_email回调函数。它永远不会进入功能。尽管如此,一切似乎都很好!

有人可以帮我解决这个问题吗?

用户型号:

public function form_rules()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        $this->form_validation->set_rules('nome', 'Nome', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email|callback_is_unique_email');
        $this->form_validation->set_rules('password', 'Password', 'required|matches[password_repeat]');
        $this->form_validation->set_rules('password_repeat', 'Repeat Password', 'required');
        if ($this->form_validation->run() == FALSE)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public function is_unique_email()
    {
        die("asadadaa");
    }

我的控制器

public function insert()
    {
        if ($this->user_model->form_rules() == FALSE) {
            $this->index();
        } else {
            echo "The form was validated!";
        }
    }

0 个答案:

没有答案