tags:

views:

157

answers:

2
+1  Q: 

Grails checkbox

+1  A: 

After much hacking it appears the answer is that grails is looking for a marker field with the name:

groups[0]._isHidden

rather than

_groups[0].isHidden

which is actually what the g:checkBox tag generates. See GrailsDataBinder.java:911 see propertyStartsWithFieldMarkerPrefix(PropertyValue pv, String fieldMarkerPrefix) for confirmation

If you are interested I've uploaded the test project for this question to gitub.com

Gareth Davis
Thanks a lot.Tom
Tom
+1  A: 

Hi gurus

I correct checkbox tag. Thanks to gid help, now it work with association too.

from source:
http://grails.org/doc/latest/ref/Tags/checkBox.html#

 if (value == null) value = false

out << "<input type=\"hidden\" name=\"_${name}\" /><input type=\"checkbox\" name=\"${name}\" "

if (value && checked) { out << 'checked="checked" ' } 

to:

if (value == null) value = false

def begin =  name.lastIndexOf('.') +1
def tail =  name.substring( begin);
out << "<input type=\"hidden\" name=\"${name.replace(  tail, "_" + tail  )}\" /><input type=\"checkbox\" name=\"${name}\" "

if (value && checked) { out << 'checked="checked" ' } 
Tom
good stuff.. I'll see if I can create a test and patch for the grails project
Gareth Davis