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!')); } }
public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('id' => $id, 'itemtype_id' => Item::find($id)->itemtype_id, 'description' => $params['description']); $item = new Item($attributes); $errors = $item->errors(); if (count($errors) > 0) { $item = Item::find($id); $itemtype = ItemType::find($item->itemtype_id); View::make('item/edit.html', array('errors' => $errors, 'given_description' => $params['description'], 'item' => $item, 'itemtype' => $itemtype)); } else { $item->update(); Redirect::to('/item/' . $item->id, array('message' => 'The item has been modified successfully!')); } }