Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
7743eecf
Commit
7743eecf
authored
Nov 04, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support #761
type Test struct { Date time.Time `form:"Date, 2006-01-02"` Save bool `form:"Save"` }
parent
c4d8e4a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
templatefunc.go
templatefunc.go
+21
-0
No files found.
templatefunc.go
View file @
7743eecf
...
...
@@ -302,6 +302,14 @@ func ParseForm(form url.Values, obj interface{}) error {
switch
fieldT
.
Type
.
Kind
()
{
case
reflect
.
Bool
:
if
strings
.
ToLower
(
value
)
==
"on"
||
strings
.
ToLower
(
value
)
==
"1"
||
strings
.
ToLower
(
value
)
==
"yes"
{
fieldV
.
SetBool
(
true
)
continue
}
if
strings
.
ToLower
(
value
)
==
"off"
||
strings
.
ToLower
(
value
)
==
"0"
||
strings
.
ToLower
(
value
)
==
"no"
{
fieldV
.
SetBool
(
false
)
continue
}
b
,
err
:=
strconv
.
ParseBool
(
value
)
if
err
!=
nil
{
return
err
...
...
@@ -329,6 +337,19 @@ func ParseForm(form url.Values, obj interface{}) error {
fieldV
.
Set
(
reflect
.
ValueOf
(
value
))
case
reflect
.
String
:
fieldV
.
SetString
(
value
)
case
reflect
.
Struct
:
switch
fieldT
.
Type
.
String
()
{
case
"time.Time"
:
format
:=
time
.
RFC3339
if
len
(
tags
)
>
1
{
format
=
tags
[
1
]
}
t
,
err
:=
time
.
Parse
(
format
,
value
)
if
err
!=
nil
{
return
err
}
fieldV
.
Set
(
reflect
.
ValueOf
(
t
))
}
}
}
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment