How can I show errors from two beans (second one being a command object) in one list?
I can do this:
<g:hasErrors beans="${bookInstance}">
<g:renderErrors bean="${bookInstance}" as="list" />
</g:hasErrors>
<g:hasErrors beans="${myCmdObject}">
<g:renderErrors bean="${myCmdObject}" as="list" />
</g:hasErrors>
but it gives me two lists. I want to do something like this:
<g:hasErrors beans="${bookInstance, myCmdObject}">
<g:renderErrors bean="${bookInstance, myCmdObject}" as="list" />
</g:hasErrors>
which will give me one list. Is there a nice way of doing this?
Yes. You can use the
modelattribute described here. It takes in a map and will render the errors of all the entries in that map. The same is true for hasErrors.Try: