Skip to content

Instantly share code, notes, and snippets.

@zh32
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zh32/4361a38c22ba04ff74f5 to your computer and use it in GitHub Desktop.
Save zh32/4361a38c22ba04ff74f5 to your computer and use it in GitHub Desktop.
public class Application extends Controller {
static Form<TestData> form = Form.form(TestData.class);
public static Result index() {
return ok(index.render(form));
}
public static Result submit() {
Form<TestData> filledForm = form.bindFromRequest(); //bindFromRequest returns "a copy of this form filled with the new data"
if (filledForm.hasErrors()) {
Logger.error("YES YOU HAVE ERRORS");
return badRequest(index.render(filledForm)); //show the form with the data
}
Logger.debug("Age:"+testData.age);
return ok(index.render(form));
}
}
@jroper
Copy link

jroper commented Jun 26, 2014

You'll need to do:

TestData testData = filledForm.get();

After the if statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment