--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 (Scala) Form 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 supportPATCH
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( mapping( "countryName" -> nonEmptyText, "countryCode" -> nonEmptyText, "currencyCode" -> nonEmptyText )(Countries.apply)(Countries.unapply) ) }
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 - usingCountries.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 https://discuss.playframework.com!
The play-framework Google Group will soon be put into read-only mode.
For details, see https://blog.playframework.com/introducing-discuss-playframework-com/.
---
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 play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/882e29e5-3fb8-4755-b138-92e4286dc843%40googlegroups.com.