1

I've only been able to find examples in java, and they all seem to suggest that what I am doing should "just work". I have a form like the following (either with the name as "id" or "id[]", both give the same results). I have tried declaring my edit method as taking List[Int] or Seq[Int], but in both cases id ends up being NULL. If I dump params, I can see that body does in fact contain the correct query string, and if I just do a get("id") it comes back as an int containing the first value (1). How can I get some sort of ordered container (don't care if it is a list or seq or whatever) submitted through a form?

<form method="post" action="">
    <input type="hidden" name="id" value="1" />
    <input type="hidden" name="id" value="2" />
    <input type="hidden" name="id" value="3" />
    <input type="hidden" name="id" value="4" />
    <input type="text" name="name" />
    <input type="submit" />
</form>

def edit(id: List[Int]) = {...}

1 Answer 1

1

Play doesn't handle scala collection types from forms, only java collections. Leaving the form as-is but changing the method to:

def edit(id: java.util.List[Int]) = {...}

Solves the problem. Then you can convert your java list into a scala list and use it normally.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.