Re: [play-framework][deprecated] Updating only changed values into MongoDB from a Form Submission

Skip to first unread message

Will Sargent

May 22, 2018, 7:37:16 PM5/22/18
Form specific case classes and object persistence models are very different, and you should map between them explicitly.  See for details.

You should check if your browser is actually sending a PATCH request to the server.  Many browsers only use GET and POST.

You may also want to check out the following for REST API example:

On Tue, May 8, 2018 at 8:36 AM, Get Yeti <> wrote:

I've been setting up a REST API in the Play Framework (2.6) in Scala and been trying to implement the use of a (ScalaForm but I'm having some difficulties when attempting to find the best practice for updating only values that have changed upon form submission. I have used this article as a reference (as well as others) and it uses the HTTP Request PATCH shown as something similar to this with the Routes file:

   PATCH  /update/:collName    controllers.IndexC.update(collName: String, oId: Option[BSONObjectID])

However if I route to this in my (Play) template for the form action like this:

   @form(action = routes.IndexC.update(collName, oId), 'method -> "patch", ...)

Then it brings up an error that it cannot locate the file (trying to use a GET request). I've read somewhere that this can happen if the browser doesn't support PATCH as a HTTP Request. Or perhaps I am completely misunderstanding this - we'll call that part 1 of my gap in knowledge.

Also (part 2 of my gap in knowledge) I am struggling to understand how only the values from the form submission can be retrieved (rather than all input box values). So suppose that I had a very simple Scala model & form looking like this:

   case class Countries(countryName: String, countryCode: String, currencyCode: String)

   object Countries {

     val form = Form(
         "countryName" -> nonEmptyText,
         "countryCode" -> nonEmptyText,
         "currencyCode" -> nonEmptyText


Is there a way bindFromRequest can help to retrieve just those input values that have changed (from the Mongo database collection and those that were fed initially into the form - using Countries.form.fill)? Or is this perhaps better done elsewhere with a more sensible approach? Or maybe part 1's solution makes this irrelevant. Many thanks.

Please join our new forum at!
The play-framework Google Group will soon be put into read-only mode.
For details, see
You received this message because you are subscribed to the Google Groups "Play Framework [deprecated]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

For more options, visit

Will Sargent

May 23, 2018, 7:56:43 PM5/23/18
to Play Framework [deprecated]
Reply all
Reply to author
0 new messages