public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('id' => $id, 'name' => $params['name'], 'pnprefix' => ItemType::find($id)->pnprefix, 'nextpn' => ItemType::find($id)->nextpn); $itemtype = new ItemType($attributes); $errors = $itemtype->errors(); if (count($errors) > 0) { $itemtype = ItemType::find($id); View::make('itemtype/edit.html', array('errors' => $errors, 'given_name' => $params['name'], 'itemtype' => $itemtype)); } else { $itemtype->update(); Redirect::to('/itemtype/' . $itemtype->id, array('message' => 'The item type has been modified successfully!')); } }