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
6c9ff81f
Commit
6c9ff81f
authored
Oct 20, 2014
by
WithGJR
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: if user didn't set id or class, then it won't be displayed in HTML code
parent
1b3e7de4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
templatefunc.go
templatefunc.go
+10
-2
No files found.
templatefunc.go
View file @
6c9ff81f
...
...
@@ -380,11 +380,19 @@ func RenderForm(obj interface{}) template.HTML {
// renderFormField returns a string containing HTML of a single form field.
func
renderFormField
(
label
,
name
,
fType
string
,
value
interface
{},
id
string
,
class
string
)
string
{
if
id
!=
""
{
id
=
"id=
\"
"
+
id
+
"
\"
"
}
if
class
!=
""
{
class
=
"class=
\"
"
+
class
+
"
\"
"
}
if
isValidForInput
(
fType
)
{
return
fmt
.
Sprintf
(
`%v<input
id="%v" class="%v"
name="%v" type="%v" value="%v">`
,
label
,
id
,
class
,
name
,
fType
,
value
)
return
fmt
.
Sprintf
(
`%v<input
%v %v
name="%v" type="%v" value="%v">`
,
label
,
id
,
class
,
name
,
fType
,
value
)
}
return
fmt
.
Sprintf
(
`%v<%v
id="%v" class="%v"
name="%v">%v</%v>`
,
label
,
fType
,
id
,
class
,
name
,
value
,
fType
)
return
fmt
.
Sprintf
(
`%v<%v
%v %v
name="%v">%v</%v>`
,
label
,
fType
,
id
,
class
,
name
,
value
,
fType
)
}
// isValidForInput checks if fType is a valid value for the `type` property of an HTML input element.
...
...
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