如何在播放框架验证中保存单选按钮状态

时间:2013-11-14 14:35:03

标签: playframework playframework-1.x

我们有以下单选按钮,将选定的按钮传递给方法

中的参数“type”
    <input type="radio" name="type" value="a">
        Selection 1
    <input type="radio" name="type" value="b">
        Selection 2
    <input type="radio" name="type" value="c">
        Selection 3

我没有的是,如果不同的字段验证失败(因此没有输入登录),那么这是唯一被清除的窗口小部件....我的所有其他字段都正确地保留了数据,因为它们有一个值= “$ {PARAMNAME}”

如何让单选按钮以这种方式工作?

感谢, 迪安

1 个答案:

答案 0 :(得分:0)

我使用formfield而不是playframeworks'field'标签,因为我有错误修复

基本上,这就是我提出的(不是最漂亮的,但它有效)......

#{formfield 'type'}
<input type="radio" name="type" value="a" #{if field.value=='a'}checked="checked"#{/if}>
    Selection 1
<input type="radio" name="type" value="b" #{if field.value=='b'}checked="checked"#{/if}>
    Selection 2
<input type="radio" name="type" value="c" #{if field.value=='c'}checked="checked"#{/if}>
    Selection 3
#{/formfield}