Java 如何在playframework中预选radiobutton-/checkbox组?

Java 如何在playframework中预选radiobutton-/checkbox组?,java,scala,templates,web,playframework,Java,Scala,Templates,Web,Playframework,我正试图用这出戏构造一个简单的形式!框架2.3.8。因此,我创建了一个radiobutton组,它可以正常工作,但是如何预先选择某个radiobutton 我在文档中没有找到与此相关的任何内容: 复选框也存在同样的问题: @helper.form(action=routes.Application.submit(),'id->“userForm”){ @helper.inputRadioGroup( 用户表单(“Geschlecht”), 期权=期权(“曼恩”->“曼恩”,“弗劳”->“弗劳

我正试图用这出戏构造一个简单的形式!框架2.3.8。因此,我创建了一个radiobutton组,它可以正常工作,但是如何预先选择某个radiobutton

我在文档中没有找到与此相关的任何内容:

复选框也存在同样的问题:

@helper.form(action=routes.Application.submit(),'id->“userForm”){
@helper.inputRadioGroup(
用户表单(“Geschlecht”),
期权=期权(“曼恩”->“曼恩”,“弗劳”->“弗劳”),
“_标签->“性别”,
'\u error->userForm(“Geschlecht”).error.map(\u.withMessage(“选择性别”))
)

有什么想法吗?

当渲染时在视图中传递表单对象时,该表单对象必须填充一个具有选定字段值的实例Geschlecht

控制器代码

UserForm user = new UserForm();
//set value of Geschlecht
user.Geschlecht = Mann;

Form<UserForm> form = Form.form(UserForm.class);
form.fill(user)

Html view = views.index.render(userForm);
UserForm user=new UserForm();
//Geschlecht的设定值
user.Geschlecht=Mann;
formform=Form.Form(UserForm.class);
填写表格(用户)
Html视图=views.index.render(userForm);
index.scala.html

@helper.form(action = routes.Application.submit(), 'id -> "userForm"){
        <fieldset>
            @helper.inputRadioGroup(
            userForm("Geschlecht"),
            options = options("Mann"->"Mann","Frau"->"Frau"),
            '_label -> "Gender",
            '_error -> userForm("Geschlecht").error.map(_.withMessage("select gender"))
            )
        </fieldset>
@helper.form(action=routes.Application.submit(),'id->“userForm”){
@helper.inputRadioGroup(
用户表单(“Geschlecht”),
期权=期权(“曼恩”->“曼恩”,“弗劳”->“弗劳”),
“_标签->“性别”,
'\u error->userForm(“Geschlecht”).error.map(\u.withMessage(“选择性别”))
)

在选项图中,它将选择与字段Geschlecht的值相同的键的条目。

谢谢,我不得不更改控制器,但理解了这个想法。非常有用的提示!
@helper.form(action = routes.Application.submit(), 'id -> "userForm"){
        <fieldset>
            @helper.inputRadioGroup(
            userForm("Geschlecht"),
            options = options("Mann"->"Mann","Frau"->"Frau"),
            '_label -> "Gender",
            '_error -> userForm("Geschlecht").error.map(_.withMessage("select gender"))
            )
        </fieldset>