Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:45:05+00:00 2026-06-17T16:45:05+00:00

How do I compare an enum in a Play Framework 2 form to an

  • 0

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) {
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:45:06+00:00Added an answer on June 17, 2026 at 4:45 pm

    You’ve said that myForm("sectionType").value is an Option[String], so you can’t use directly toString, because Some("hello").toString return “Some(hello)”.

    I suggest trying with this syntax:

    myForm("sectionType").value.get == SectionType.MAIN_CONTACT_INFO.toString
    // or .getOrElse("") to avoid errors
    

    And don’t forget to import SectionType if necessary (ie. if this class is not in the models package)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to compare the attribute value in jQuery? example if( $(this).[ attribute
How do I do a simple compare of an enum value and a string
i'm trying to compare a value to an Enum in Struts: <s:if test=%{myValue ==
I need to create a enum value something like this' DESIGN & BUILD'. I
What's the best way in code to compare enum values? For example, if I
I have written code to TryParse enum either by value or by its name
If enum implements Comparable so why can't compare with < or >? public class
How can I compare a enum to a variable if the enum contains mulitple
I have this filetypeenum: public enum FileType : int { jpeg = 0, png
I am having a problem getting this COMPARE macro to work. Any ideas on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.