1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 13:10:54 +00:00

refactoring code after discussion

This commit is contained in:
Witaya Tospitakkul 2019-01-25 11:00:24 +07:00
parent bd1b421491
commit 3bd7614ade

View File

@ -297,23 +297,17 @@ func parseFormToStruct(form url.Values, objT reflect.Type, objV reflect.Value) e
tag = tags[0]
}
if fieldT.Type.Kind() == reflect.Slice {
found := false
for _, v := range form[tag] {
if len(v) != 0 {
found = true
break
}
}
if !found {
formValues := form[tag]
var value string
if len(formValues) == 0 {
continue
}
}
value := form.Get(tag)
if (fieldT.Type.Kind() != reflect.Slice) && len(value) == 0 {
if len(formValues) == 1 {
value = formValues[0]
if value == "" {
continue
}
}
switch fieldT.Type.Kind() {
case reflect.Bool: