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 9094841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:27:00+00:00 2026-06-16T23:27:00+00:00

I have a simple model object: case class Region(id: String, revision: Option[String], name: String)

  • 0

I have a simple model object:

case class Region(id: String, revision: Option[String], name: String)

object Region {        
    // Returns Some(region) if successful, None if revision doesn't match the latest
    // in the data store
    def insertOrUpdate(region: Region): Promise[Option[Region]]
}

In my controller I want to do something like this but I don’t know how to indicate the lock failure in the response. I would like to add a global form error but can’t see how from the API.

def update(id: String) = Action {
    implicit request => regionForm.bindFromRequest.fold(
        formWithErrors => BadRequest(views.html.regions.edit(formWithErrors)),        
        region => Async{
            Region.insertOrUpdate(region).map{
                _ match {
                    case None => {
                    // How do I add a global form error indicating there were server side changes detected
                        BadRequest(views.html.regions.edit(regionForm.fill(region))
                    }
                    case Some(r) => Redirect(views.html.regions.index).flashing(("success", "Update successful")
            }
        }
    )
}
  • 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-16T23:27:01+00:00Added an answer on June 16, 2026 at 11:27 pm

    For Play 2.0.4

    A global error is in reality an error without key (see globalErrors method).

    There is no helper to add an error, but you can do it by yourself, with something like that:

    regionForm.fill(region)
      .copy(errors = FormError("", "Your Error Message") +: errors)
    

    For Play 2.1

    You can use the withGlobalError method:

    regionForm.fill(region)
      .withGlobalError("Your error message")))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name
Assume I have such simple model: class Foo(models.Model): name = models.CharField(max_length=25) b_date = models.DateField()
I have a domain model that looks like this: case class Account(id: Int, name:
I have a simple question regarding accessing member variables of a model object. I
I have a simple model like this: class User < ActiveRecord::Base serialize :preferences end
I have a simple model class (Part), which pulls from it's information from a
Suppose I have a simple model, such as Record: @Model public class Record {
My data model is simple: class Neighborhood(models.Model): name = models.CharField(max_length = 50) slug =
I have a simple model like this class UserType( models.Model ) : def __unicode__(
I have a Simple insert and update test for a table: case class Player(id:

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.