public function action_edit($id = null) { $type = Model_Type::find($id); $val = Model_Type::validate('edit'); if ($val->run()) { $type->type_name = Input::post('type_name'); if ($type->save()) { Session::set_flash('success', e('Updated type #' . $id)); Response::redirect('site/types'); } else { Session::set_flash('error', e('Could not update type #' . $id)); } } else { if (Input::method() == 'POST') { $type->type_name = $val->validated('type_name'); Session::set_flash('error', $val->error()); } $this->template->set_global('type', $type, false); } $this->template->title = "Types"; $this->template->content = View::forge('site/types/edit'); }