first post to this forum ...
The Grails 2.0.1 < field type="number" > doesn't seem to be working out of the box, but perhaps my usage is incorrect, so I'm looking here for a sanity check.
Here's the field in my domain entity:
Long locationId
static constraints = {
locationId(blank: false)
}
Here's the resulting field in the scaffolded-template generated _form.gsp:
<g:field type="number" name="locationId" required="" value="${fieldValue(bean: myEntityInstance, field: 'locationId')}"/>
But here's the result in the html, as per "view source":
<input type="number" name="locationId" required="" value="" id="locationId" />
And my problem is that the form blanks out the existing value of that field, as per: value="". The other fields (all strings) are populated correctly. Is the Grails 2.0.1 "number" gsp field working correctly for other people?
Regards Rob
Try:
<g:field type="number" name="locationId" required="" value="${myEntityInstance.locationId}"/>
If you have any value of 4 or more figures like 1000, fieldValue tries to display it 1,000
Check the actual value of ${fieldValue(bean: myEntityInstance, field: 'locationId')}
Print it out
<%
System.out.println fieldValue(bean: myEntityInstance, field: 'locationId')
%>
i've not had a problem with the 'number' type, it works for me exactly as you have used it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.