File tree 3 files changed +39
-0
lines changed
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ func main() {
23
23
24
24
authorized := r .Group ("/" , authMiddleware .MiddlewareFunc ())
25
25
authorized .GET ("/" , adminView .Index )
26
+ authorized .POST ("/" , adminView .SendLoad )
26
27
27
28
r .Run (":8000" )
28
29
}
Original file line number Diff line number Diff line change 1
1
<h1>Hello, Loadcentral Admin!</h1>
2
2
<a href="/logout">Logout</a>
3
+
4
+ <form method="POST" id="loadcentral_form">
5
+ <label for="phone_number">Phone number: </label>
6
+ <input type="text" name="phone_number[]">
7
+ <label for="pcode">Pcode: </label>
8
+ <select name="pcode[]">
9
+ <option value="GMX100">Globe 100</option>
10
+ <option value="SM100">Smart 100</option>
11
+ </select>
12
+ <br>
13
+
14
+ <label for="phone_number">Phone number: </label>
15
+ <input type="text" name="phone_number[]">
16
+ <label for="pcode">Pcode: </label>
17
+ <select name="pcode[]">
18
+ <option value="GMX100">Globe 100</option>
19
+ <option value="SM100">Smart 100</option>
20
+ </select>
21
+ <br>
22
+
23
+ <input type="submit">
24
+ </form>
25
+
26
+ <p>{{ .error }}</p>
Original file line number Diff line number Diff line change @@ -10,3 +10,17 @@ type Admin struct{}
10
10
func (admin Admin ) Index (c * gin.Context ) {
11
11
c .HTML (http .StatusOK , "index.tmpl" , nil )
12
12
}
13
+
14
+ func (admin Admin ) SendLoad (c * gin.Context ) {
15
+ type sendLoadForm struct {
16
+ PhoneNumber []string `form:"phone_number[]" binding:"required"`
17
+ Pcode []string `form:"pcode[]" binding:"required"`
18
+ }
19
+
20
+ var form sendLoadForm
21
+ if err := c .ShouldBind (& form ); err != nil {
22
+ c .HTML (http .StatusOK , "index.tmpl" , gin.H {"error" : err .Error ()})
23
+ return
24
+ }
25
+ c .HTML (http .StatusOK , "index.tmpl" , nil )
26
+ }
You can’t perform that action at this time.
0 commit comments