Forms 游戏框架与形式
我目前正在使用Play框架,但是关于表单的信息似乎很少 现在我得到的东西看起来像这样: 路线是:Forms 游戏框架与形式,forms,playframework,playframework-2.0,Forms,Playframework,Playframework 2.0,我目前正在使用Play框架,但是关于表单的信息似乎很少 现在我得到的东西看起来像这样: 路线是: GET /test controllers.Application.testMethod() 方法: public static Result testMethod(){ //handles the Form } NameResidencePair类: public static class NameResidencePair{ public String name; pub
GET /test controllers.Application.testMethod()
方法:
public static Result testMethod(){
//handles the Form
}
NameResidencePair类:
public static class NameResidencePair{
public String name;
public String residence;
}
包含表单的scala.html页面
@(aForm: Form[NameResidencePair])
@import helper._
@form(action = routes.Application.testMethod) {
@inputText(
field = userForm("name")
)
@inputText(
field = userForm("residence")
)
}
如果我仍然想要一个表单,但是其中一个值,比如居住,总是相同的值呢。示例:residence=“云上”。我仍然想通过表单传递它,但我不想要文本字段。换句话说,我想传递一个带有姓名和住址的表单,但只有姓名应该是可编辑的,并且在输入字段中可见。显而易见的解决方案是隐藏表单字段:
<input type="hidden" name="residence" value="On a cloud">
用于创建隐藏字段,但将该行粘贴到代码中不应太费力。:-)
但请不要,仅仅因为它是隐藏的,你不能假设它的值总是“在云上”。这仅仅意味着“表单字段是隐藏的”,用户仍然可以发送任意值。因此,请仍然检查用户输入