Grails default error message text field name override?
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.
精彩评论