我有两个模型之间的映射,Movie
并且Place
. 当我现在创建一个从movieForm
并填写一个已经创建Movie
并打开的视图时,movieForm
会填充一个包含所有文本字段和选择的视图,除了映射Place
到Movie
. 在下面的示例中,在视图的“选择”中选择了正确的类别,但未选择该地点。
可能是什么问题?我该如何解决这个问题?
电影模特
@Entity
public class Movie extends Model {
@Id
public Long id;
...
@Required
@Formats.NonEmpty
public EnumCategorie categorie = EnumCategorie.FILM;
@ManyToOne
public Place place;
...
}
放置模型
@Entity
public class Place extends Model {
@Id
public String name;
...
}
控制器
public class Movies extends Controller {
public static Result edit(Long id) {
Movie movie = Movie.find.byId(id);
Form<Movie> movieForm = form(Movie.class).fill(movie);
return ok(movieCreate.render(movieForm,
placeForm, "edit"));
}
风景
@form(routes.Movies.save(option)) {
<fieldset>
...
@select(movieForm("categorie"),
options(Movie.categories),
'_label -> "Categories", '_default -> "-- Choose a categorie --",
'_showConstraints -> false,
'class -> "controls")
@select(movieForm("place"),
options(Place.places),
'_label -> "Places", '_default -> "-- Choose a place --",
'_showConstraints -> false,
'class -> "controls")
...
</fieldset>