How to create an html form for a model in playframework

In my application, I have to present the user with an address input form . I have an Address model as below. Do I need to create an html page from scratch to capture user input, Or can I generate a form similar to the crud page in admin ? What 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; ... } 
+1
source share
2 answers

Using a CRUD module to capture user input is simpler and faster. For such cases, there is a CRUD module. Regarding whether this is correct, it depends. You have a lot of settings, then you can override crud templates and this should work.

Just create an address controller that extends CRUD. It will be available as part of / admin /. Here it is.

0
source

You can reuse CRUD tags without CRUD controllers!

 #{crud.form class:'models.ModelName' /} #{curd.form object:anyInstance /} 

See my answer for more details. Advanced configuration of CRUD forms and controllers in Play .

PS.

This question has already been asked, but the accepted question was not satisfactory for me, and I wanted to ask him a more general question. So I asked him again, but still not getting an answer, I finally found a solution myself :)

+3
source

Source: https://habr.com/ru/post/904783/


All Articles