$state = $this->grocery_crud->getState(); if($state == 'insert_validation'){ $this->grocery_crud->set_rules('id_thn_ajaran','Thn ajaran','required|is_unique[tahun_ajaran.id_thn_ajaran]'); }elseif($state == 'update_validation'){ $this->grocery_crud->set_rules('id_thn_ajaran','Thn ajaran','callback_thn_ajaran_check'); } /////// public function thn_ajaran_check($str){ $this->form_validation->set_message('thn_ajaran_check', 'The Thn ajaran already exists'); return false; }