0

The questions is all in the title :)

Using Play! Framework 2.0, I have a Model with a ManyToOne field to an other Model.

In the form, I show it with a Select id -> toString, but when I hit submit, I've got "Invalid value", because it expect an instance of that Model (I guess).

How can I do this?

Thanks for your help!

4

1 回答 1

4

此选择的名称必须设置为property.id

IE。如果你的模型看起来像

@Entity
public class Entry extends Model {

    @Id
    public Long id;

    public String title;

    @ManyToOne
    public User user;
}    

你的选择应该这样写:

@select(
    yourForm("user.id"),
    options(User.options),
    'id -> "user",
    '_label -> "Select user"
)
于 2012-04-24T09:35:21.530 回答