I\'m trying to use the automatic binding feature of Play, without success. I\'m developing in Java, on Eclipse 4.4 Luna.
Here is my form :
There is absolutely no link between the binding and your database. Do not follow @blackbishop's advice telling you to change all the fields of your model to String. That's a very bad idea, if there are different types, there is a reason...
Moreover, Ebean (supposing you're using it) or JPA generate database column types according to your Java properties type. Why would you store a 0 or a 1 in a varchar column ?
Follow these rules :
User instead of Users)That should give you this :
public static Result createUser() {
Form form = Form.form(User.class).bindFromRequest();
if (form.hasErrors()) {
// Do what you have to do (i.e. : redirect to the form with a flash message)
}
User u = form.get();
u.save();
return redirect(routes.Backend.allUsers());
}
By the way, in your testing lines, the user_id is correctly generated because you have no validation rules and this data comes from the database, not the form.