0

我有这个表格工作,老实说我不知道​​我可能做了什么。表单现在不会提交,我没有看到任何表单验证错误。

控制器:

    $this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<div class="ncerror" >', '</div>');
    $this->form_validation->set_rules('media_consent', 'Media Consent', 'required');
    $this->form_validation->set_rules('aic_name', 'Name', 'required');
    $this->form_validation->set_rules('aic_phone', 'Cell phone', 'required');
    $this->form_validation->set_rules('aic_email', 'Email', 'required');

    if ($this->form_validation->run() == FALSE) {
        $data = $this->ncformdata();
        $this->load->view('templates/sponsorheader', array('title' => 'National Convention Registration'));

        var_export($_POST);
        $this->load->view('ncform', $this->ncformdata());
        $this->load->view('templates/footer2');
    } 

我有

<?php echo "errors" . validation_errors();

在我的表格顶部。提交表单后,表单重新加载,显示“错误”,但没有来自 validation_errors 函数的其他输出。对故障排除有任何帮助吗?

4

2 回答 2

0

你有一个条件

$this->form_validation->run() == FALSE

但是当表单验证返回 TRUE 时,我看不到任何条件。尝试添加条件时

$this->form_validation->run() == TRUE

例子:

 if ($this->form_validation->run() == FALSE) {
        $data = $this->ncformdata();
        $this->load->view('templates/sponsorheader', array('title' => 'National Convention Registration'));
        var_export($_POST);
        $this->load->view('ncform', $this->ncformdata());
        $this->load->view('templates/footer2');

}
else
{ 
        echo 'There are no form validation errors!.';
}
于 2015-02-11T07:36:34.663 回答
0

这条线应该

 $this->load->view('ncform', $this->ncformdata());

是这个吗?

 $this->load->view('ncform', $data);
于 2015-02-11T00:01:17.430 回答