Esempio n. 1
0
 public function action_add($Id = null)
 {
     //もしPOST送信されたら
     if (Input::method() == 'POST') {
         $val = Model_Collection::validate('add');
         if ($val->run()) {
             $collection = Model_Collection::forge(array('title' => Input::post('title'), 'created' => date('Y-m-d H:i:s'), 'modified' => date('Y-m-d H:i:s'), 'col_code' => Input::post('col_code'), 'save_space' => Input::post('save_space'), 'assort_id' => Input::post('assort_id'), 'picture_id' => Input::post('picture_id'), 'note' => Input::post('note')));
             //もしデータが保存されたら
             if ($collection and $collection->save()) {
                 Session::set_flash('success', '<span class="btn btn-primary span9 btn-block">ID-' . $collection->id . 'の『' . $collection->title . '』を追加しました</span><br>');
                 //indexページへ移動
                 Response::redirect('collection/index');
             } else {
                 Session::set_flash('error', '保存できませんでした');
             }
         } else {
             Session::set_flash('error', $val->show_errors());
         }
     }
     $colassorts = Model_Colassort::find('all');
     foreach ($colassorts as $row) {
         $data['assorts'][$row->id] = $row->as_name;
     }
     $this->template->content = View::forge('collection/add', $data);
 }