Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Modified package

Cette révision appartient à :
akuma06 2017-05-06 18:02:54 +02:00
Parent d32c3d0fa8
révision 2bf2d02c8a

Voir le fichier

@ -3,7 +3,7 @@ package modelHelper
import ( import (
"reflect" "reflect"
"github.com/dorajistyle/goyangi/util/log" "github.com/ewhal/nyaa/util/log"
) )
func IsZeroOfUnderlyingType(x interface{}) bool { 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))
}
}