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,9 +20,11 @@ type Form interface {
20 20
 }
21 21
 
22 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 30
 func FormValue(fp *FormParams, key string) string {
@@ -36,7 +38,12 @@ func FormValue(fp *FormParams, key string) string {
36 38
 	switch OperatingEnvironment() {
37 39
 
38 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 48
 	case WebBrowserEnvironment:
42 49