I am learning the Play framework and I am learning CRUD controllers. I want to make a form to add new posts but I have a compilation error. As I am new to scala I cannot figure out the error.
@(productForm: Form[Product])
@import helper._
@import helper.twitterBootstrap._
@main("Product Form"){
<h1>Product Form</h1>
@helper.form(action = routes.Products.save()){
<fieldset>
<legend>Product (@productForm("name").valueOr("New")) </legend>
@helper.inputText(@productForm("ean"), '_label -> "EAN")
@helper.inputText(@productForm("name"), '_label -> "Name")
@helper.textarea(@productForm("description"), '_label -> "Description")
</fieldset>
<input type="submit" class="btn btn-primary" value="Save">
<a class="btn" href="@routes.Products.index()">Cancel</a>
}
}
the error is:
/Users/andrei/Desktop/PlayFramework/app/views/products/details.scala.html:11: illegal start of simple expression
[error] @helper.inputText(@productForm("ean"), '_label -> "EAN")
another problem:I define in the class a private static final variable, but I get an error. I think it's due to a deprecated library as I am learning the framework from a 2014 book
import play.api.data.Form;
import play.api.FormFactory;
public class Products extends Controller {
Form<Product> productForm = formFactory.form(Product.class);
the error:
cannot find symbol
symbol: variable formFactory
location: class controllers.Products
source to documentation where I've found FormFactory: https://www.playframework.com/documentation/2.5.x/JavaForms