In my form, I've defined a drop-down:

@select(
myForm("category_id"),
options(Category.options()),
'_label -> "Category",
'_default -> "-- Choose a Category --",
'_showConstraints -> false
)

in my controller code:

Form<Category> catForm = form(Category.class).bindFromRequest();
if(catForm.hasErrors()) {
return badRequest(categoryEdit.render(catForm));
}

The form submission does not allow me to select the default value and catForm.hasErrors() is true if I make no selection. Two questions:

  1. How do I allow default value to be selected in the dropdownlist?

  2. I want the default value to be -1, where to set it? (Maybe this is where the problem is, there is no value associated with -- Choose a Category -- option?)

Edit
Report