hasErrors with indexed property
        Posted  
        
            by Micor
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Micor
        
        
        
        Published on 2010-04-12T21:35:12Z
        Indexed on 
            2010/04/12
            23:42 UTC
        
        
        Read the original article
        Hit count: 313
        
I am having hard time getting hasErrors to work with indexed properties. For example
class Order {
  String prop1
  String prop2
  static hasMany = [items: Item]
}
class Item {
  String name
  static constraints = {
    name(blank:false)
  }
}
Validation works properly and on item.name being blank I do get an error with
<g:renderErrors bean="${orderInstance}"/>
However, I am trying to have input box highlighted using hasErrors :
<g:each in="${orderIntsance.items}" status="i" var="item">
  <span class="field ${hasErrors(bean: orderInstance, field: ????????? , 'errors')}">
    <g:textField name="items[${i}].name" value="${item?.name}"/>
  </span>
</g:each>
Not sure how to get to it with a field: property, any ideas?
Thanks
© Stack Overflow or respective owner