I have problems binding a Boolean property in association classes. The property is true if I check (good), but null if checbox is not set.
I know the problem with the HTML checkbox. I know why "_fieldName" is sent in the parameters, but this "_fieldName" does not set my boolean property to false .
class Person{ String title List<Group> groups = new ArrayList() static hasMany = [groups: Groups] } class Group{ String title Boolean isHidden static belongTo = Person } class PersonController{ def form = { def person = new Person() person.groups.add( new Group() ) return ["person": person] } def handleForm = { def person = new Person( params ) println person.groups[0] } } <g:form action="save"> <g:textField name="title" value="${person?.title}" /> <g:textField name="groups[0].title" value="${person?.groups[0]?.title}"/> <g:checkBox name="groups[0].isHidden" value="${person?.groups[0]?.isHidden}" /> <g:submitButton name="save" value="Save" /> </g:form>
If I check the box:
[isHidden: on, title: a, _isHidden:]
println person.groups [0] // true
If I do not check the box:
[title: a, _isHidden:]
println person.groups [0] // null
Thank you for help
Tom
Sorry, I was looking for this network but did not receive actual information about my problem.
grails
Tomáš
source share