public function action_edit($id = null) { if ($user_type = Model_User_Type::find($id)) { $val = Model_User_Type::validate('edit'); if ($val->run()) { $user_type->name = Input::post('name'); $user_type->group = Input::post('group'); if ($user_type->save()) { Session::set_flash('success', e('Updated user_type #' . $id)); Response::redirect('admin/user/types/view/' . $user_type->id); } else { Session::set_flash('error', e('Could not update user_type #' . $id)); } } else { if (Input::method() == 'POST') { $user_type->name = $val->validated('name'); $user_type->group = $val->validated('group'); Session::set_flash('error', $val->error()); } $this->template->set_global('user_type', $user_type, false); } $this->template->set_global('groups', $this->get_groups()); $this->template->title = "Employee Types » " . $user_type->name . " » Edit"; $this->template->content = View::forge('admin/user/types/edit'); } else { Fuel\Core\Session::set_flash('error', 'Cannot find the selected item'); Fuel\Core\Response::redirect('admin/user/types'); } }