Java 在Play 2.4中的循环中创建InputRadioGroup

Java 在Play 2.4中的循环中创建InputRadioGroup,java,html,forms,playframework,playframework-2.0,Java,Html,Forms,Playframework,Playframework 2.0,我正在寻找一种在for循环中创建具有不同名称和值的inputRadioGroups的方法 例如,我有一份10位申请人的名单。index.scala.html显示每个申请者的姓名,并向用户提供3个单选按钮(雇用、拒绝、可能) 这就是我目前得到的。问题是,每个组都有相同的名称、值和ID。所以我只能选择30个选项中的一个(当然,我想选择10个,每组1个)。此外,如何更改代码,使其能够处理每个选择的结果 @helper.form(action = routes.Application.save(), '

我正在寻找一种在for循环中创建具有不同名称和值的
inputRadioGroup
s的方法

例如,我有一份10位申请人的名单。index.scala.html显示每个申请者的姓名,并向用户提供3个单选按钮(雇用、拒绝、可能)

这就是我目前得到的。问题是,每个组都有相同的名称、值和ID。所以我只能选择30个选项中的一个(当然,我想选择10个,每组1个)。此外,如何更改代码,使其能够处理每个选择的结果

@helper.form(action = routes.Application.save(), 'id -> "userForm") {
<fieldset>
    @for(applicant <- applicants) {
    <hr>
    <h3>@applicant.getName()</h3>
    <h4>Decision</h4>
    @helper.inputRadioGroup( userForm("status"), options =
    Seq("hire"->"Hire", "decline"->"Decline", "maybe"->"Maybe"), '_label ->
    "Language", '_error ->
    userForm("status").error.map(_.withMessage("select something"))) 
    }
</fieldset>
<div class="actions">
    <input type="submit" value="Save" class="btn btn-primary">
</div>
}
@helper.form(action=routes.Application.save(),'id->“userForm”){
@对于(申请人“雇佣”、“拒绝”->“拒绝”、“可能”->“可能”),“\u标签->
“语言”,错误->
userForm(“status”).error.map(u.withMessage(“select something”))
}
}

我找到了解决方案:最好的方法是使用自定义HTML输入,如下所述:

@helper.form(action=routes.Application.save(),'id->“userForm”){
@(申请人)
租用
火
大概
}
}
}
@helper.form(action = routes.Application.save(), 'id -> "userForm") {
<fieldset>
    @for(applicant <- applicants) {
    <hr>
    <h3>@applicant.getName()</h3>
            <h4>Decision</h4>

            @helper.input(userForm("status")) { (id,name,value,args) =>
            <div class="radio">
                <label> <input type="radio"
                    name="name_@applicant.getId" id="option1_id_@applicant.getId"
                    value="value1" @toHtmlArgs(args)>Hire
                </label>
            </div>
            <div class="radio">
                <label> <input type="radio"
                    name="name_@applicant.getId" id="option2_id_@applicant.getId"
                    value="value2" @toHtmlArgs(args)> Fire
                </label>
            </div>
            <div class="radio">
                <label> <input type="radio"
                    name="name_@applicant.getId" id="option3_id_@applicant.getId"
                    value="value3" @toHtmlArgs(args)> Maybe
                </label>
            </div>
            }
    }
</fieldset>
<div class="actions">
    <input type="submit" value="Save" class="btn btn-primary">
</div>
}