Browse Source

Added functionality to validate form using the supplied form fields in the form params struct

Wirecog 7 years ago
parent
commit
df9ec24f41
1 changed files with 11 additions and 4 deletions
  1. 11
    4
      form.go

+ 11
- 4
form.go View File

20
 }
20
 }
21
 
21
 
22
 type FormParams struct {
22
 type FormParams struct {
23
-	ResponseWriter http.ResponseWriter
24
-	Request        *http.Request
25
-	FormElement    *dom.HTMLFormElement
23
+	ResponseWriter             http.ResponseWriter
24
+	Request                    *http.Request
25
+	FormElement                *dom.HTMLFormElement
26
+	UseFormFieldsForValidation bool
27
+	FormFields                 map[string]string
26
 }
28
 }
27
 
29
 
28
 func FormValue(fp *FormParams, key string) string {
30
 func FormValue(fp *FormParams, key string) string {
36
 	switch OperatingEnvironment() {
38
 	switch OperatingEnvironment() {
37
 
39
 
38
 	case ServerEnvironment:
40
 	case ServerEnvironment:
39
-		result = fp.Request.FormValue(key)
41
+
42
+		if fp.UseFormFieldsForValidation == true {
43
+			result = fp.FormFields[key]
44
+		} else {
45
+			result = fp.Request.FormValue(key)
46
+		}
40
 
47
 
41
 	case WebBrowserEnvironment:
48
 	case WebBrowserEnvironment:
42
 
49