Got a weird issue with g:checkbox not being saved when its switched from on to off for a child in one-to-many relationship. For example:
class Parent {
Boolean enabled
static hasMany = [children: Child]
static constraints = {
enabled(blank: true, nullable: true)
}
}
class Child {
Boolean enabled
static belongsTo = [parent: Parent]
static constraints = {
enabled(blank: true, nullable: true)
}
}
Posting to Parent controller true/false values will work for Parent:
<g:checkBox name="enabled" value="${parentInstance?.enabled}"/>
However, not for Child! When posting to Parent controller I can only go from false to true, trying to change from true to false again will not work:
<g:each in="${parentInstance.children}" status="i" var="child">
<g:checkBox name="child[${i}].enabled" value="${child?.enabled}" />
</g:each>
That seems to be a bug. Any ideas? Thanks.