如何在playframework中为模型创建一个html表单 [英] how to create an html form for a model in playframework
问题描述
在我的应用程序中,我必须向用户呈现地址输入表单
。我有一个地址
模型如下所示。我是否需要从头开始创建一个html页面来捕获用户输入,或者我可以生成一个类似于admin 区域中的 crud页面的表单?在
playframework
?
public class Address extends模型{
@所需
字符串addressLine1;
字符串addressLine2;
字符串城市;
字符串状态;
字符串pincode;
字符串phoneNumber;
字符串国家;
...
}
使用CRUD模块来捕捉用户输入是更简单快捷的方式。 CRUD模块适用于这种情况。关于这是否是正确的方式,这取决于。你有很多的定制,那么你可以覆盖crud模板,它应该工作。
只需创建一个扩展CRUD的地址控制器。它将作为/ admin /的一部分提供。那就是它。
In my application ,I have to present the user with an address input form
.I have an Address
model as given below.Do I need to create an html page from scratch to capture the user input,Or can I generate a form similar to the crud page in admin
area?Which is the correct way to do this in playframework
?
public class Address extends Model {
@Required
String addressLine1;
String addressLine2;
String city;
String state;
String pincode;
String phoneNumber;
String country;
...
}
Using CRUD module to capture user input is easier and quicker way. CRUD Module exists for such cases. Regarding whether this is the correct way, it depends. It you have lot of customization then you can overide the crud templates and it should work.
Just create a Addresses Controller extending CRUD. It would be available as part of /admin/. Thats it.
这篇关于如何在playframework中为模型创建一个html表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!