您好我正在注册页面。这就是我的表单:
$app->get('/user/registration', function() use($app) {
$app->render('registration.html');
});
$app->post('/user/reg-link', function() use($app) {
$request = \Slim\Slim::getInstance()->request()->post();
if($request['txt_un'] == "") {
// $app->redirect back with form still filled up
} else {
echo "good job";
}
});
在我的路线文件中:
username
我想要做的是,如果Document.Builder builder = Document.newBuilder()
.addField(Field.newBuilder().setName("location").setGeoPoint(new GeoPoint(lat, lon)))
.addField(Field.newBuilder().setName("radius").setNumber(radiusInMeter));
字段为空,则重定向回表单但电子邮件字段在提交之前仍必须包含该值。我怎么能这样做?
答案 0 :(得分:2)
Slim框架附带flash()模块。您可以添加这些代码
$app->flash('txt_un', $request["txt_un"]);
$app->flash('email', $request["email"]);
$app->redirect(your redirect path);
在您的注册页面中,将您的代码修改为
<input type="text" name="txt_un" value="{{flash.txt_un}}">
<input type="text" name="email" value="{{flash.email}}">