コード例 #1
0
ファイル: Card_controller.php プロジェクト: vmoulin77/DVB
 public function create()
 {
     $this->output->enable_profiler(true);
     $this->load->model('Card');
     $this->form_validation->set_rules('num', 'Number', 'required|integer');
     $this->form_validation->set_rules('word_english', 'English', 'required');
     $this->form_validation->set_rules('word_french', 'French', 'required');
     $this->layout->add_basic_assets()->menu();
     if ($this->form_validation->run() === false) {
         $default_num = Card::get_max_num() + 1;
         $data = array('num' => $default_num, 'word_english' => '', 'word_french' => '', 'is_active_english' => true, 'is_active_french' => true);
         $create_edit = $this->layout->views('controllers/Card/actions/create_edit', $data, array('css', 'js'), true);
         $this->layout->action_view(array('create_edit' => $create_edit));
     } else {
         $result = Card::insert((int) $this->input->post('num'), $this->input->post('word_english'), $this->input->post('word_french'), $this->input->post('is_active_english'), $this->input->post('is_active_french'));
         if ($result === true) {
             $this->layout->view('others/form_success');
         } elseif ($result instanceof Standard_error) {
             $this->layout->views('others/form_failure', array('message' => $result->message));
             $data = array('num' => $this->input->post('num'), 'word_english' => $this->input->post('word_english'), 'word_french' => $this->input->post('word_french'), 'is_active_english' => $this->input->post('is_active_english'), 'is_active_french' => $this->input->post('is_active_french'));
             $create_edit = $this->layout->views('controllers/Card/actions/create_edit', $data, array('css', 'js'), true);
             $this->layout->action_view(array('create_edit' => $create_edit));
         }
     }
 }