Selaa lähdekoodia

Rooms added to Census Validator - census Form
Closes #14,#13,#9,#8

Andrew Grant 7 kuukautta sitten
vanhempi
commit
2ee3c59b85

+ 1 - 1
src/main/java/scot/carricksoftware/grants/validators/census/CensusCommandValidator.java

@@ -30,7 +30,7 @@ public class CensusCommandValidator {
 
     private void validateRoomsInhabited(CensusCommand censusCommand, BindingResult bindingResult) {
         if (notANonNegativeInteger(censusCommand.getInhabitedRooms())) {
-            bindingResult.rejectValue("roomsInhabited", ApplicationConstants.EMPTY_STRING,
+            bindingResult.rejectValue("inhabitedRooms", ApplicationConstants.EMPTY_STRING,
                     null,
                     ValidationConstants.FIELD_NOT_NEGATIVE_INTEGER);
         }

+ 22 - 0
src/main/resources/templates/census/form.html

@@ -90,6 +90,28 @@ rounded-3 text-center p-4">
                 </div>
             </div>
         </div>
+        <div class="form-group row justify-content-center">
+            <div class="col-md-3">
+                <label for="inhabitedRooms">Inhabited Rooms</label>
+                <input class="form-control" id="inhabitedRooms"
+                       th:field="*{inhabitedRooms}" type="text">
+                <div th:if="${#fields.hasErrors('inhabitedRooms')}">
+                    <ul class="text-danger">
+                        <li th:each="err : ${#fields.errors('inhabitedRooms')}" th:text="${err}"/>
+                    </ul>
+                </div>
+            </div>
+            <div class="col-md-3">
+                <label for="roomsWithWindows">Rooms With Windows</label>
+                <input class="form-control" id="roomsWithWindows"
+                       th:field="*{roomsWithWindows}" type="text">
+                <div th:if="${#fields.hasErrors('roomsWithWindows')}">
+                    <ul class="text-danger">
+                        <li th:each="err : ${#fields.errors('roomsWithWindows')}" th:text="${err}"/>
+                    </ul>
+                </div>
+            </div>
+        </div>
         <button type="submit" class="btn btn-primary">Commit</button>
         <a class="btn btn-secondary" th:href="@{/censuses}" th:text="${'List all'}">List all</a>
         <a class="btn btn-success" th:href="@{/}" th:text="${'Home'}">Home</a>