我正在使用gocart并开始处理那个,插入到数据库工作正常但在编辑它时显示错误。此问题仅适用于某些页面
我的控制器
函数表单($ id = false) { $ this-> email_id = $ id; $这 - >负载>库( 'form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
//default values are empty if the product is new
$data['id'] = '';
$data['subject'] = '';
$data['email'] ='';
$data['body'] ='';
$data['signature'] ='';
$this->breadcrumb->append_crumb('Home', base_url().'admin');
$this->breadcrumb->append_crumb('Email', base_url().'admin/email');
if ($id)
{
$email = $this->email_model->get_email($id);
//if the product does not exist, redirect them to the product list with an error
if (!$email)
{
$this->session->set_flashdata('error', lang('error_not_found'));
redirect($this->config->item('admin_folder').'/email/form');
}
$data['page_title'] ='Email - '.$email->subject;
//set values to db values
$data['id'] = $id;
$data['email'] = $email->email;
$data['subject'] = $email->subject;
$data['body'] = $email->body;
$data['signature'] = $email->signature;
$this->breadcrumb->append_crumb($email->subject, base_url().'email/form');
}else{
$data['page_title'] = 'Email';
$this->breadcrumb->append_crumb('Email', base_url().'email/form');
}
$data['breadcrumb']=$this->breadcrumb->output();
/*//no error checking on these
$this->form_validation->set_rules('caption', 'Caption');
$this->form_validation->set_rules('primary_photo', 'Primary');*/
$this->form_validation->set_rules('email', 'lang:email', 'trim|required|valid_email');
$this->form_validation->set_rules('subject', 'lang:subject', 'trim|required|max_length[64]');
$this->form_validation->set_rules('body', 'lang:body', 'trim|required|max_length[250]');
$this->form_validation->set_rules('signature', 'lang:signature', 'trim|required|max_length[64]');
if ($this->form_validation->run() == FALSE)
{
$this->load->view($this->config->item('admin_folder').'/email/email_form', $data);
}
else
{
$this->load->helper('text');
$save['id'] = $id;
$save['email'] = $this->input->post('email');
$save['body'] = $this->input->post('body');
$save['subject'] = $this->input->post('subject');
$save['signature'] = $this->input->post('signature');
// save product
$email_id = $this->email_model->save_email($save);
$this->session->set_flashdata('message', lang('message_saved_product'));
//go back to the product list
redirect($this->config->item('admin_folder').'/email');
}
}
1)这里我没有使用slug功能 2)htaccess文件没问题 3)编辑和插入在同一个控制器中