public function update() { $this->load->library('form_validation'); $period_id = intval($this->input->post('period_id')); $this->form_validation->set_rules('period_id', 'id', 'required'); $this->form_validation->set_rules('period[name]', 'lang:admin_periods_form_field_name', 'required|callback__is_unique_name_not_in[' . $period_id . ']'); $this->form_validation->set_message('_is_unique_name_not_in', $this->lang->line('admin_periods_form_error_message_is_unique_name_not_in')); if ($this->form_validation->run()) { $period = new Period(); $period->get_by_id($period_id); if ($period->exists()) { $period_data = $this->input->post('period'); $period->from_array($period_data, array('name')); $this->_transaction_isolation(); $this->db->trans_begin(); if ($period->save() && $this->db->trans_status()) { $this->db->trans_commit(); $this->messages->add_message('lang:admin_periods_flash_message_save_successful', Messages::MESSAGE_TYPE_SUCCESS); $this->_action_success(); } else { $this->db->trans_rollback(); $this->messages->add_message('lang:admin_periods_flash_message_save_failed', Messages::MESSAGE_TYPE_ERROR); } } else { $this->messages->add_message('lang:admin_periods_error_period_not_found', Messages::MESSAGE_TYPE_ERROR); } redirect(create_internal_url('admin_periods/index')); } else { $this->edit(); } }