$editForm->getField("id")->setTemplate('partials/formInputs/id.twig'); $editForm->load($id); if ($app->request->isPost()) { $formResponse = $app->request->post(); $editForm->populate($formResponse); $editForm->save(); $app->redirect('/contribute'); } $app->view()->display('contribute-edit.twig', array('modelName' => $model, 'fieldList' => $editForm->toArray())); })->via('POST', 'GET'); $app->map('/login', function () use($app) { $error = false; if ($app->request->isPost()) { $userName = $app->request->post('userName'); $password = $app->request->post('password'); $user = \SpoilerWiki\User::authenticate($userName, $password); if ($user) { $_SESSION['user_id'] = $user->getId(); $app->redirect('/contribute'); } else { $error = true; } } $app->view()->display('login.twig', array("register_redirect" => $app->request->get('registered'), "forbidden" => $app->request->get('forbidden'), "error" => $error)); })->via('POST', 'GET'); $app->map('/register', function () use($app) { $errors = array(); if ($app->request->isPost()) { $userName = $app->request->post('userName'); $emailAddress = $app->request->post('emailAddress'); $password = $app->request->post('password');