public function action_create() { if (Input::method() == 'POST') { $val = Model_Post::validate('create'); if ($val->run()) { $post = Model_Post::forge(array('title' => Input::post('title'), 'small_description' => Input::post('small_description'), 'content' => Input::post('content'), 'category_id' => Input::post('category_id'), 'user_id' => $this->current_user->id)); if (\Security::check_token() and $post and $post->save()) { Session::set_flash('success', e('Added post #' . $post->id . '.')); Response::redirect('blog/admin/post'); } else { if (!\Security::check_token()) { Session::set_flash('error', e('Could not save post, CSRF token not valid!')); } else { Session::set_flash('error', e('Could not save post.')); } } } else { Session::set_flash('error', $val->error()); } } $this->template->title = "Posts"; $this->template->content = View::forge('admin/post/create'); }