Exemple #1
0
 public function action_create()
 {
     $this->template->title = __("Thêm hình ảnh slide");
     $this->template->section_title = __("Thêm hình ảnh slide");
     $data = array();
     if (Request::$method == "POST") {
         $img = new ImageSlide();
         $post = $img->validate_create($_POST);
         if ($post->check()) {
             $post = $post->as_array();
             $img->src = $post['src'];
             $img->slide_position = $post['slide_position'];
             $img->url = $post['url'];
             $img->order = intval($post['order']);
             $img->User = Auth::instance()->get_user();
             $img->description = $post['description'];
             $img->save();
             Message::success('Thêm mới hình ảnh slide thành công!');
             Request::instance()->redirect('/admin/slide/index');
         } else {
             $data['errors'] = $post->errors('admin/slide');
             $_POST = $post->as_array();
         }
     }
     $this->template->content = View::factory('admin/slide/create', $data);
 }