Reputation: 159
I am using Grails 3. I have the following field:
<g:field id="myVar" name="myVar" type="number" value="${this.myController?.myVar}"/>
Domain class:
class myDomain{
int myVar
static constraints ={
myVar nullable:true, blank:true
}
}
When I try to submit this field, it will not allow a blank answer. I have it set up in my constraints in the domain class that this field can be null and blank. All of the number fields inside of my form are giving me this error, yet I can leave other fields blank. This is the error message:
Property myVar is type-mismatched
Is there a setting I am missing?
Upvotes: 0
Views: 114
Reputation: 530
int is a primitive type. It will never be null. You should have Integer. Also you should remove "blank" constraint. It make sense only for String type.
Upvotes: 2