How do I compare an enum in a Play Framework 2 form to an enum value? This statement fails even when they are equal.
@if(myForm("sectionType").value == SectionType.MAIN_CONTACT_INFO) {
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ve said that
myForm("sectionType").valueis anOption[String], so you can’t use directlytoString, becauseSome("hello").toStringreturn “Some(hello)”.I suggest trying with this syntax:
And don’t forget to import
SectionTypeif necessary (ie. if this class is not in the models package)