mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 04:01:29 +00:00
refactoring code after discussion
This commit is contained in:
parent
bd1b421491
commit
3bd7614ade
@ -297,24 +297,18 @@ func parseFormToStruct(form url.Values, objT reflect.Type, objV reflect.Value) e
|
|||||||
tag = tags[0]
|
tag = tags[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if fieldT.Type.Kind() == reflect.Slice {
|
formValues := form[tag]
|
||||||
found := false
|
var value string
|
||||||
for _, v := range form[tag] {
|
if len(formValues) == 0 {
|
||||||
if len(v) != 0 {
|
continue
|
||||||
found = true
|
}
|
||||||
break
|
if len(formValues) == 1 {
|
||||||
}
|
value = formValues[0]
|
||||||
}
|
if value == "" {
|
||||||
if !found {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value := form.Get(tag)
|
|
||||||
if (fieldT.Type.Kind() != reflect.Slice) && len(value) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch fieldT.Type.Kind() {
|
switch fieldT.Type.Kind() {
|
||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
if strings.ToLower(value) == "on" || strings.ToLower(value) == "1" || strings.ToLower(value) == "yes" {
|
if strings.ToLower(value) == "on" || strings.ToLower(value) == "1" || strings.ToLower(value) == "yes" {
|
||||||
|
Loading…
Reference in New Issue
Block a user