I have a attribute called status in my domain which is String type can have any one of two values Applied , NotApplied
I have two check boxes to input this value. in my edit page i want to display these two check box.
If the value of status is Applied then the corresponding checkbox must be checked.
my code
<g:message code="publicRuleInstance.course.label" default="Applied" />
<g:checkBox name="status " value="${publicRuleInstance?.status }" />
<g:message code="publicRuleInstance.course.label" default="NotApplied" />
<g:checkBox name="status " value="${publicRuleInstance?.status }" />
but here both the checkboxes are checked.
there must be a way to check the value i.e if the status = Applied then that perticular checkbox must be cheched else it should be unchecked.
Is there any way to doing it?
Use the
checkedattribute to control the state of your checkBox as described in the docs.Here you could add any expression to determine the state of the
g:checkBox:If you just want to allow one of the values –
AppliedorNotApplieda g:radioGroup would be the better choice. With a checkBox the user could choose both valuesAppliedandNotApplied.