Search code examples
grailscheckboxgsp

Pass checkbox value to controller from GSP in Grails


I've a checkbox in my Grails application:

<g:checkBox name="reservationAvailable" value="${cafeeInfo.isReservationAvailable}"/>

It must be uncheked if isReservationAvailable boolean-value is false and checked if it's true. When I click on unchecked checkbox, it become checked, then I send a form, but in logs of controller I get false checkbox value. When I update view page, checkbox become empty again. Using parsing such as:

oldCafeeInfo.isReservationAvailable = Boolean.parseBoolean(params['reservationAvailable'])

doesn't solve my issue.


Solution

  • I noticed, checkbox return "on" string, when it's checked. So available to compare checkbox parameter in response with "on"-constant.