1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 03:21:29 +00:00

Merge pull request #3621 from guanle/guanle-patch-1

Update templatefunc.go  for default value tag
This commit is contained in:
astaxie 2019-04-27 23:28:35 +08:00 committed by GitHub
commit 6123c72752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,8 +300,13 @@ func parseFormToStruct(form url.Values, objT reflect.Type, objV reflect.Value) e
formValues := form[tag] formValues := form[tag]
var value string var value string
if len(formValues) == 0 { if len(formValues) == 0 {
defaultValue := fieldT.Tag.Get("default")
if defaultValue != "" {
value = defaultValue
} else {
continue continue
} }
}
if len(formValues) == 1 { if len(formValues) == 1 {
value = formValues[0] value = formValues[0]
if value == "" { if value == "" {