I have a checkbox on my GSP page as follows (which was stolen directly from the scaffolded "create" code for my domain object)...
<tr class="prop">
<td valign="top" class="name">
<label for="isSelling"><g:message code="person.isSelling.label" default="Is Selling" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: personInstance, field: 'isSelling', 'errors')}">
<g:checkBox name="isSelling" value="${personInstance?.isSelling}" />
</td>
</tr>
This works just fine, except when I look at the elements in the resulting form I have a hidden checkbox alongside the real one...
<tr class="prop">
<td valign="top" class="name">
<label for="isSelling">Is Selling</label>
</td>
<td valign="top" class="value ">
<input type="hidden" name="_isSelling" />
<input type="checkbox" name="isSelling" id="isSelling" />
</td>
</tr>
My questions are:
Just inspecting what happens when the checkbox gets set on and off in my page, it appears that the hidden one is ignored, so I am imagining there is some cunning processing going on when the submit action occurs which looks at the _isSelling and isSelling for some magical purpose. Anyone have any insight into what Grails is doing?
Thanks
That's a spring thing. It adds that checkbox so that unchecked boxes are accountable. Some browsers won't push any information about an unchecked box so the hidden box is added to prevent binding errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With