PlayFramework,如何从表单中的其他模型绑定多个值?

时间:2013-07-03 20:48:12

标签: forms playframework-2.1

我有两个这样的模型:

MyModel
    public Long id;
    public String display;
    public List<OtherModel> others;

OtherModel
    public Long id;
    public String display;

    public static HashMap<String, String> listAsOptions() // Returns a list of <Id, Display> items for the select

在我的表格中,我做了一个像这样的选择:

@helper.select(form("others[]"), helper.options(models.OtherModel.listAsOptions), '_label -> "Others", 'id -> "form-others", '_showConstraints -> false, 'class -> "span3", 'multiple -> "multiple")

问题位于此输入的名称,此处为others[]:它不起作用!

通常,由于我们与其他模型相关,我们应将其映射为others[].id,但ID也不起作用。

我试过这些(没有运气):

  • others.id
  • others.id []
  • 其他[]。ID
  • 其他
  • 其他[]

错误取决于名称,但它永远不会有效。

我怎样才能让它发挥作用?

0 个答案:

没有答案