adrianhurt/play-bootstrap

Select field missing required tags when type is not String

Closed this issue · 1 comments

Hi,

Just stumbled upon the following issue. I have a FormRequest where a list of Users needs to be selected. My FormRequest looks (simplified of course):

@Constraints.Validate
public class UserForm implements Constraints.Validatable<List<ValidationError>> {
    public Long id;
    @Constraints.Required
    public User user;
}

In my view I am using the following:

@b3.select(form("user.id"), userList.map(t => t.getId.toString -> t.getName), '_default -> "Please select", '_label -> "User", 'class -> "select2able")

I have noticed that no required attribute is generated when I am using form("user.id").
But when I use form("user") the required attribute is generated.

Is this a bug or by design?

Hi @adis-me. Sorry for answering so late. I understand your question, but it is a functionality provided by play.api.data.Field, so you could ask it directly to the Play Framework repository. This plugins simply get the list of constraints provided by Field object and render them for you.