Esempio n. 1
0
 public function add()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->library('session');
     $this->form_validation->set_message('isValidColor', '%s موجود نمی باشد.');
     if ($this->form_validation->run('task/add') === FALSE) {
         $this->load->view("templates/errorForm.php", array("fields" => array('color', 'task')));
     } else {
         $task = new Task();
         try {
             $task->make($this->input->post("task"), $this->input->post("color"))->save(new User($this->session->getStudentId()));
             $this->load->view("task/task_created");
         } catch (Task_Whit_This_Name_Already_Exist $e) {
             $this->load->view("task/task_error.php");
             Task_Error::Task_Whit_This_Name_Already_Exist();
         }
     }
 }