Loïc Guillois
Loïc Guillois

Reputation: 373

Play! 2.1 Forms broken after updating a Play! 2.0 app

The simple code snippet speaks for itself.

[error]   Form<User> userForm = Form.form(User.class).bindFromRequest();
[error]                             ^
[error]   symbol:   method form()
[error]   location: class Form

I've checked documentation : http://www.playframework.com/documentation/2.1.0/JavaForms

Doesn't understand what's going on...

The documentation is clear about that :

http://www.playframework.com/documentation/2.1.0/Migration

and the Java API is clear too :

http://www.playframework.com/documentation/api/2.1.0/java/play/data/Form.html#form(java.lang.Class)

Upvotes: 0

Views: 406

Answers (2)

Vinayak Sakhare
Vinayak Sakhare

Reputation: 808

Form<User> userForm = form(User.class);

OR

DynamicForm requestData = form().bindFromRequest();

Shifting from play 2.0.x to 2.1.x gives error for above code.

solution:

play.data.Form.* is a static import.

use import static play.data.Form.*; in your file & error will get resolved.

Upvotes: 4

Alban Dericbourg
Alban Dericbourg

Reputation: 1634

The form method has been moved in version 2.1.

Check that you are actually using play.data.Form.form() (it was previsously in play.mvc.Controller.Form if I remember well).

If you did change that, try a play clean clean-all and re-run a compilation. It should work then...

Upvotes: 3

Related Questions