From f6149996e94a713e78c1f8c4c55a72b6f3b62e7d Mon Sep 17 00:00:00 2001
From: Rhys Nute <nuterd@cardiff.ac.uk>
Date: Wed, 13 Dec 2023 04:54:29 +0000
Subject: [PATCH] updated form

---
 .../Organisation/organisationControllers.java |  4 +--
 .../localauthority/localAuthority.java        |  8 ++---
 .../resources/templates/local-auth-data.html  | 32 +++++++++----------
 .../templates/local-authorities.html          |  4 +--
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
index dbb21d3a..4e25da2a 100644
--- a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
+++ b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
@@ -31,10 +31,10 @@ public class organisationControllers {
     }
     @Autowired
     private localAuthorityRepository localAuthorityRepository;
-    @PostMapping("/local-auth-data1")
+    @PostMapping("/local-auth-data")
     public ModelAndView localAuthSent(@Valid @ModelAttribute("localAuthority")localAuthority localAuthority, BindingResult bindingResult, Model model ) {
         if (bindingResult.hasErrors()){
-            ModelAndView modelAndView = new ModelAndView("local-auth-data1", model.asMap());
+            ModelAndView modelAndView = new ModelAndView("local-auth-data", model.asMap());
             return modelAndView;
         }else{// converts user input using the organisation constructor into a submittable format to the sql table
 
diff --git a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java
index 3a07cde4..7bed36b9 100644
--- a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java
+++ b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java
@@ -19,7 +19,7 @@ public class localAuthority {
     private URL website;
     @Override
     public String toString() {
-        return "localAuthority{" +
+        return "localAuthority" +
                 localAuthorityName + '\'' +
                 address1 + '\'' +
                 address2 + '\'' +
@@ -27,16 +27,14 @@ public class localAuthority {
                 county + '\'' +
                 postcode + '\'' +
                 website +
-                '}';
+                '.';
     }
 
     public String getLocalAuthorityName() {
         return localAuthorityName;
     }
 
-    public String getAddress1() {
-        return address1;
-    }
+    public String getAddress1() { return address1; }
 
     public String getAddress2() {
         return address2;
diff --git a/src/main/resources/templates/local-auth-data.html b/src/main/resources/templates/local-auth-data.html
index dd217e1f..3a3dd609 100644
--- a/src/main/resources/templates/local-auth-data.html
+++ b/src/main/resources/templates/local-auth-data.html
@@ -11,30 +11,30 @@
 <body>
 <div id="container1">
     <h2>Enter your Local authority</h2>
-        <form action="/local-auth-data1" id="data" name="data" method="post">
+        <form action="/local-auth-data" id="data" name="data" method="post" th:object="${localAuthority}">
                 <br>
-                <label for="localAuthorityName">Enter your local authority
-                    <input type="text" field="localAuthorityName" name="authority_name" id="localAuthorityName">
+                <label>Enter your local authority
+                    <input type="text" th:field="*{localAuthorityName}">
                 </label><br><br>
-                <label for="address1">Please enter first line of your address
-                    <input type="text" name="address_1" id="address1">
+                <label>Please enter first line of your address
+                    <input type="text" th:field="*{address1}">
                 </label><br><br>
-                <label for="address2">Please enter second line of your address (optional)
-                    <input type="text" name="address_2" id="address2">
+                <label>Please enter second line of your address (optional)
+                    <input type="text" th:field="*{address2}">
                 </label><br><br>
-                <label for="city">Please enter the City/Town
-                    <input type="text" name="city" id="city">
+                <label>Please enter the City/Town
+                    <input type="text" th:field="*{city}">
                 </label><br><br>
-                <label for="county">Please enter you county (optional)
-                    <input type="text" name="county" id="county">
+                <label>Please enter you county (optional)
+                    <input type="text" th:field="*{county}">
                 </label><br><br>
-                <label for="postcode">Please enter your postcode
-                    <input type="text" name="post_code" id="postcode">
+                <label>Please enter your postcode
+                    <input type="text" th:field="*{postcode}">
                 </label><br><br>
-                <label for="website">Please enter your website address
-                    <input type="url" name="web_site" id="website">
+                <label>Please enter your website address
+                    <input type="text" th:field="*{website}">
                 </label><br><br>
-            <input type="submit" value="Submit">
+            <input type="submit">
         </form>
 </div>
 </body>
diff --git a/src/main/resources/templates/local-authorities.html b/src/main/resources/templates/local-authorities.html
index ecf80b64..e416d25f 100644
--- a/src/main/resources/templates/local-authorities.html
+++ b/src/main/resources/templates/local-authorities.html
@@ -10,8 +10,8 @@
 <body>
 <h1>Local Authorities</h1>
 <div id="councils">
-    <ul th:each="localauthorities:${localAuthority}">
-        <li th:text="${localauthorities}"></li>
+    <ul th:each="localAuthority:${localAuthority}">
+        <li th:text="${localAuthority}"></li>
     </ul>
 </div>
 <a href="/localForm" id="authority"><button>Local Authorities please enter here</a></button>
-- 
GitLab