システムに患者を追加するためのこのコード スニペットがありますが、エラー メッセージは表示されません。ビューにvalidation_errors()
はありますが、まだ何も表示されていません ここにコードがあります
// Add a new item
public function add()
{
//some form validation rules here
$this->form_validation->set_error_delimiters('<div class="alert alert-error"><i class="icon-exclamation-sign"></i>', '</div>');
$this->form_validation->set_rules('patient_type_id','Patient Type Id','required|trim|xss_clean|integer');
$this->form_validation->set_rules('first_name','First Name','required|trim|xss_clean|max_length[50]');
$this->form_validation->set_rules('middle_name','Middle Name','required|trim|xss_clean|max_length[50]');
$this->form_validation->set_rules('last_name','Last Name','required|trim|xss_clean|max_length[50]');
$this->form_validation->set_rules('gender','Gender','required|trim|xss_clean');
$this->form_validation->set_rules('age','Age','required|trim|xss_clean|max_length[3]|integer');
$this->form_validation->set_rules('address','Address','required|trim|xss_clean');
$this->form_validation->set_rules('status','Status','required|trim|xss_clean');
$this->form_validation->set_rules('contact_number','Contact Number','required|integer|trim|xss_clean');
$this->form_validation->set_rules('email','Email','trim|xss_clean|email|required');
//check if the rules are pass
if($this->form_validation->run()){
//if pass save it to the database
$results = $this->model_nurse_patient->add();
if($results == TRUE){
Console::log('data saved into the database');
$message= "<i class='icon-exclamation-sign'></i>You have successfully added a new patient<br>";
$this->session->set_flashdata('success', $message);
redirect(base_url('nurse/patient'));
}else{
Console::log('data was not saved');
$message= "<i class='icon-exclamation-sign'></i>Failed to add a new patient";
$this->session->set_flashdata('error', $message);
redirect(base_url('nurse/patient'));
}
}else{
//show the form again with errors
Console::log('validation not passed');
$this->create();
}
}
これは $this->create() のコードです。ヘッダー、フッター、およびビューのみを取得します
public function create(){
//just showing the add patient form
Console::log($this->model_nurse_patient->get_all_patient_type());
$create_data['list_rel_status'] = $this->model_nurse_patient->get_all_relationship_status();
$create_data['list_patient_type'] = $this->model_nurse_patient->get_all_patient_type();
$this->nurse_patient_header(array('title'=> 'EHR v1'));
$this->load->view('users/nurse/patient/create',$create_data);
$this->nurse_patient_footer();
}