My controller has this (testing) code:
println domainInstance.hasErrors()
render (view: "edit", model: [domainInstance: domainInstance])
the println prints false to the console, but the gsp renders errors using <g:hasErrors>.
Why would this be happeining?
It would help if you showed the GSP code, but my guess is that
hasErrors()returns true, because you haven’t calledvalidate().The
hasErrors()method doesn’t perform validation, but just reports whether errors were detected the last time validation was performed. So I suspect that some time after the call tohasErrors()and before the call to<g:hasErrors>validation is being performed.Anyhow, if you replace the call to
with
that should fix it