From 2bf2d02c8a2072c0873819ad69ba07404cfc9bdc Mon Sep 17 00:00:00 2001 From: akuma06 Date: Sat, 6 May 2017 18:02:54 +0200 Subject: [PATCH] Modified package --- util/modelHelper/modelHelper.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/modelHelper/modelHelper.go b/util/modelHelper/modelHelper.go index 7c44ba7b..9972abf4 100644 --- a/util/modelHelper/modelHelper.go +++ b/util/modelHelper/modelHelper.go @@ -3,7 +3,7 @@ package modelHelper import ( "reflect" - "github.com/dorajistyle/goyangi/util/log" + "github.com/ewhal/nyaa/util/log" ) func IsZeroOfUnderlyingType(x interface{}) bool { @@ -25,3 +25,13 @@ func AssignValue(model interface{}, form interface{}) { } } } + +// AssignValue assign form values to model. +func BindValueForm(form interface{}, r *http.Request) { + r.ParseForm() + formElem := reflect.ValueOf(form).Elem() + typeOfTForm := formElem.Type() + for i := 0; i < formElem.NumField(); i++ { + formField := formElem.Field(i).Set(r.PostFormValue(typeOfTForm.Field(i).Name)) + } +} \ No newline at end of file