我尝试了许多不同的方法,包括添加 $this->load->helper(array('form', 'url'));
到 autoload.php 等等。
当我填写名字和姓氏的值时,没有其他内容并按提交,它只是重定向回同一页面(而不是 clientRegistrationSuccess.php),如if{} else{}
表格(查看)
echo validation_errors();
echo form_open('index/pages/clientcreation',$CustCreationFormAttr);
echo form_label('First Name: ','fname');
echo form_input($CustCreationFirstName);echo '<br>';
echo form_label('Last Name: ','lname');
echo form_input($CustCreationLastName);echo '<br>';
echo form_label('Title: ', 'title');
echo form_input($CustCreationClientTitle);echo '<br>';
echo form_label('Company: ', 'co');
echo form_input($CustCreationCompany);echo '<br>';
echo form_label('Email: ','email');
echo form_input($CustCreationEmail);echo '<br>';
echo form_submit($CustCreationSubmit,'Submit');
控制器
class Clientcreation extends CI_Controller
{
function index(){
####################################
$this->load->view('navigation');
$this->load->view('pages/clientcreation');
$this->load->view('footer');
####################################
$this->load->helper(array('form', 'url'));
$this->load->library( array('form_validation') );
## Set Validation
$this->form_validation->set_rules('fname', 'First Name', 'required');
$this->form_validation->set_rules('lname', 'Last Name', 'required');
## Perform Validation
if ($this->form_validation->run() == FALSE){
$this->load->view('pages/clientcreation');
}
else{
$this->load->view('pages/success/clientRegistrationSuccess');
}
}
}
此外,表单正在按预期加载......比如:
路径也匹配,因为如果我改变$this->load->view('pages/clientcreation');
它$this->load->view('pages/hi');
就是调用这个视图。我在这里做错了什么?