Have tried to lookup info in a lot of doc, but seem to not find the right answer.
My scenario: 1. Create Object by using Form (GUI) 2. Submit - save. 3. Reopen the object (picking from the list) 4. Edit the object 5. Save the updates to an existing object.
The problem seems how to bind the ID of the existing object to an field on the Form.
Thanks.
Bård
See the code from example for updating object
public static Result update(Long id) {
Form<Computer> computerForm = form(Computer.class).bindFromRequest();
if(computerForm.hasErrors()) {
return badRequest(editForm.render(id, computerForm));
}
computerForm.get().update(id);
flash("success", "Computer " + computerForm.get().name + " has been updated");
return GO_HOME;
}
Whole sample is available in your play directory or on github
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With