As per the docs, we can use localized data binding. But this is not working in grails 4.
controller
import grails.databinding.BindingFormat
class TestController {
def index() {
render view: 'index'
}
def test(DateCommand command) {
render "${params} <br/><br/> - ${command.errors?.collect { error -> error as String }?.join(', ')}"
}
}
class DateCommand {
@BindingFormat(code = 'date.field.format')
Date aDate
@BindingFormat('dd/MM/yyyy')
Date bDate
static constraints = {
aDate(nullable: false)
bDate(nullable: false)
}
}
index view
<g:form action="test">
<input type="text" name="aDate" value="27/04/2019" />
<input type="text" name="bDate" value="27/04/2019" />
<g:submitButton class="btn btn-success" name="OK" />
</g:form>
messages.properties
date.field.format=dd/MM/yyyy
Same code is working fine in grails 3.x.x
Am I missing some configuration or something is wrong in the code?
Am I missing some configuration or something is wrong in the code?
It looks like the annotation handling may be broken for that. If you file an issue at https://github.com/grails/grails-core/issues we can get it straightened out.
Thanks for the feedback.