From 83184be153948f9d4584a498cb23b8808d03d711 Mon Sep 17 00:00:00 2001 From: mbgame94 Date: Fri, 31 Mar 2017 12:00:47 +0530 Subject: [PATCH] Unique category Unique category --- application/controllers/Categories.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/Categories.php b/application/controllers/Categories.php index c52b883..1e56596 100644 --- a/application/controllers/Categories.php +++ b/application/controllers/Categories.php @@ -13,7 +13,9 @@ public function index(){ public function create(){ $data['title'] = 'Create Category'; - $this->form_validation->set_rules('name', 'Name', 'required'); + $this->form_validation->set_rules('name', 'Name', 'required|is_unique[categories.name]', array( + 'is_unique' => 'This Category already exists.' + )); if($this->form_validation->run() === FALSE){ $this->load->view('templates/header'); @@ -34,4 +36,4 @@ public function posts($id){ $this->load->view('posts/index', $data); $this->load->view('templates/footer'); } - } \ No newline at end of file + }