user1292049
user1292049

Reputation: 21

Grails <field type="number" ...> not working ...?

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

Upvotes: 2

Views: 3489

Answers (2)

Vantalk
Vantalk

Reputation: 376

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

Upvotes: 1

aldrin
aldrin

Reputation: 4572

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

Upvotes: 0

Related Questions