Grails checkbox
Posted
by Tomáš
on Stack Overflow
See other posts from Stack Overflow
or by Tomáš
Published on 2010-05-30T06:38:26Z
Indexed on
2010/05/30
6:42 UTC
Read the original article
Hit count: 507
grails
Hi gurus
I have trouble with binding Boolean property in association classes. Property is set to true if I check checkbox (good), but is null if checbox is not checked.
I know the problem with HTML checkbox. I know why is send "_fieldName" in params, but this "_fieldName" dont 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]
}
}
If I check checkbox:
[isHidden:on, title:a, _isHidden:]
println person.groups[0] //true
If I don check checkbox:
[title:a, _isHidden:]
println person.groups[0] //null
Thank a lot for help
Tom
I am sorry, I searched this web, but did not get actual info for my trouble.
© Stack Overflow or respective owner