anish samant
anish samant

Reputation: 193

th:field gives default value as 0 in input field

I have a problem as mentioned in the title.
The input field is of type number.
The th:field refers to an int attribute in the database.
I want my placeholder to be visible instead of the default 0 value.

<input id="courseCredits"  name="courseCredits" th:field="*{courseCredits}" class="form-control" placeholder="Course Credits" type="number" min="0" required autofocus/>

Upvotes: 3

Views: 1430

Answers (2)

aknlol8652
aknlol8652

Reputation: 37

Change 'int' to 'Integer' in your entity class.

Upvotes: 1

Metroids
Metroids

Reputation: 20487

If you don't want the default of 0 you can't use an int. Instead use an Integer with null for empty.

Upvotes: 2

Related Questions