我的代码:
public function add()
{
if ($this->input->post())
{
//echo '<pre>';print_r($this->input->post());exit;
$this->form_validation->set_rules('agency[title]','Title','required');
$this->form_validation->set_rules('agency[first_name]','First Name','trim|required|min_length[3]');
$this->form_validation->set_rules('agency[last_name]','Last Name','trim|required|min_length[3]');
$this->form_validation->set_rules('agency[email]','Email','trim|required|valid_email|is_unique[agency.email]');
$this->form_validation->set_rules('password','Password','trim|required|min_length[3]');
$this->form_validation->set_rules('conf_password','Confirm Password','required|matches[password]');
$this->form_validation->set_rules('agency[agency_unique_id]','Agency Unique ID','trim|required|min_length[3]|is_unique[agency.agency_unique_id]');
$this->form_validation->set_rules('agency[vat_registered]','VAT Registered','trim|min_length[3]');
$this->form_validation->set_rules('agency_profile[address1]','Address 1','trim|required|min_length[3]');
$this->form_validation->set_rules('agency_profile[address2]','Address 2','trim');
$this->form_validation->set_rules('agency_profile[address3]','Address 2','trim');
$this->form_validation->set_rules('agency_profile[town]','Town','trim|required|min_length[3]');
$this->form_validation->set_rules('agency_profile[postcode]','Post Code','trim|required');
$this->form_validation->set_rules('agency_profile[phone]','Phone','trim|required|integer|exact_length[11]');
$this->form_validation->set_message('is_unique','%s is already Present. Plesae Provide a diffrent value');
if($this->form_validation->run() != FALSE)
{
//i never reach this part..
}
else
{
echo validation_errors();exit;
// no errors is printed on the screen.
}
}
$data['middle'] = 'agency/add';
$this->load->view('template/template',$data);
}
答案 0 :(得分:0)
您需要在视图页面顶部回复以下声明,而不是控制器页面
<?php echo validation_errors(); ?>
控制器页面:
if($this->form_validation->run() != FALSE)
{
//i never reach this part..
}
else
{
//here load your view page...
}