This is probably a ridiculously easy question, but I've been struggling with it nonetheless.
I have a form:
.
.
.
<g:form controller='somecontroller' action='someaction'>
<g:textField name='name'/>
<g:checkBox name='active'/>
<g:submitButton name='save'/>
</g:form>
.
.
.
And I have a command object:
class MyCommandObject{
String name
Boolean active
static constraints{
.
.
.
}
}
When I try to access the active property of the command object in my controller, it's always false. The name property, however, is being properly populated. I've tried changing the value to true, and also ${true} (as I saw in some example) and none seem to work. What am I doing wrong here?
Edit: How I'm binding to the command object in the controller:
class MyController{
.
.
.
def save(MyCommandObject cmd){
// Do validation/error checking
def myDomainObject = new DomainObject()
myDomainObject.name = cmd.name
myDomainObject.active = cmd.active
// Do something with myDomainObject
}
}
I've also tried the style:
def save = { MyCommandObject cmd ->
.
.
.
}
trueorfalsecorrectly when Iprintln cmd.activedoing exactly what you are. Have you tried agrails clean- not sure what else to try. Everything you've done looks fine as long as your actual form has the correct controller and action and no typo's your demo form above doesn't show. - Kelly