forked from ungerik/go-start
/
submitbutton.go
32 lines (30 loc) · 1003 Bytes
/
submitbutton.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package view
type SubmitButton struct {
ViewBaseWithId
Name string
Value interface{}
Class string
Disabled bool
TabIndex int
OnClick string
OnClickConfirm string // Will add a confirmation dialog for onclick
}
func (self *SubmitButton) Render(ctx *Context) (err error) {
ctx.Response.XML.OpenTag("input")
ctx.Response.XML.AttribIfNotDefault("id", self.id)
ctx.Response.XML.AttribIfNotDefault("class", self.Class)
ctx.Response.XML.Attrib("type", "submit")
ctx.Response.XML.AttribIfNotDefault("name", self.Name)
ctx.Response.XML.AttribIfNotDefault("value", self.Value)
if self.Disabled {
ctx.Response.XML.Attrib("disabled", "disabled")
}
ctx.Response.XML.AttribIfNotDefault("tabindex", self.TabIndex)
if self.OnClickConfirm != "" {
ctx.Response.XML.Attrib("onclick", "return confirm('", self.OnClickConfirm, "');")
} else {
ctx.Response.XML.AttribIfNotDefault("onclick", self.OnClick)
}
ctx.Response.XML.CloseTag()
return nil
}