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