2
votes

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

2

2 Answers

1
votes

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

0
votes

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