Grails

g:checkBox doesn't set to false booleans of domain objects bound to a sub-hash of params.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.0.2
  • Component/s: None
  • Labels:
    None

Description

The hidden field generated by g:checkBox places the underscore at the beginning of the checkBox's name even if the name has periods (dots) in it, so that it's not included when binding a "sub-hash" of params to a domain object. For example, if the Book class has a paperback boolean, then a checkbox declared as:

<g:checkBox name="book.paperback" />

and bound in the controller with:

new Book(params['book'])

or:

book.properties = params['book']

will not set the paperback property to false if the checkbox is unchecked. This is because the hidden field generated by the g:checkBox tag has the name _book.paperback. Changing this (for example, by using straight HTML instead of the g:checkBox tag) to book._paperback seems to fix the problem, which suggests that the g:checkBox tag should prepend the _ to the last component of the dotted name, rather than to the name as a whole.

Issue Links

Activity

Hide
Jeff Brown added a comment -

fixed

Show
Jeff Brown added a comment - fixed
Hide
Dmitri Vassilenko added a comment -

This has surfaced again. I can see the fix is not working in 1.3.7. Could someone please reopen this?

Show
Dmitri Vassilenko added a comment - This has surfaced again. I can see the fix is not working in 1.3.7. Could someone please reopen this?
Hide
Dmitri Vassilenko added a comment -

Whoops, sorry. I see that GRAILS-6313 has been opened to address this.

Show
Dmitri Vassilenko added a comment - Whoops, sorry. I see that GRAILS-6313 has been opened to address this.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: