public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('id' => $id, 'name' => $params['name'], 'primaryattribute' => $params['primaryattribute'], 'damagetype' => $params['damagetype'], 'attacktype' => $params['attacktype'], 'primaryrole' => $params['primaryrole'], 'description' => $params['description']); $hero = new Hero($attributes); $errors = $hero->errors(); if (count($errors) > 0) { View::make('hero/edit.html', array('errors' => $errors, 'attributes' => $attributes)); } else { $hero->update(); Redirect::to('/hero/' . $hero->id, array('message' => 'Heroa on muokattu onnistuneesti!')); } }