开发者

Grails default error message text field name override?

开发者 https://www.devze.com 2023-02-25 02:55 出处:网络
In Grails we have default messages - this is great except where my field name is not what I would like.For example I have a property name such as propertyName and the message comes out: \"propertyName

In Grails we have default messages - this is great except where my field name is not what I would like. For example I have a property name such as propertyName and the message comes out: "propertyName is required" What I would like is "property name is required"

In other words can I override开发者_Go百科 what Grails uses for arg[0]?

tia, Claude


If you consider such example:

class Foo {

  String propertyName

  static constraints = {
    propertyName blank: false
  }

}

if you provide such key in your messages.properties(message bundle file):

foo.propertyName.blank=property name is required - you will get what you want. Read the docs - default messages for constraints are explained and also how you can provide your own error codes. This is more flexible than providing own parameters for already embedded messages. If you tneed to, you can still embed arguments.

0

精彩评论

暂无评论...
验证码 换一张
取 消