form.go
1.04 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Beego (http://beego.me/)
// @description beego is an open-source, high-performance web framework for the Go programming language.
// @link http://github.com/astaxie/beego for the canonical source repository
// @license http://github.com/astaxie/beego/blob/master/LICENSE
// @authors astaxie
package forms
import (
"github.com/astaxie/beego/forms/elements"
)
type Form struct {
elements map[string]elements.ElementInterface
}
func NewForm() *Form {
f := &Form{}
f.elements = make(map[string]elements.ElementInterface)
return f
}
func (f *Form) Init() *Form {
f.elements = make(map[string]elements.ElementInterface)
}
func (f *Form) Valid(data map[string]interface{}) bool {
for k, val := range data {
if e, ok := f.elements[k]; ok {
if !e.Valid(val) {
return false
}
}
}
return true
}
func (f *Form) SetData() {
}
func (f *Form) Bind() {
}
func (f *Form) SaveData() {
}
func (f *Form) AddElement(e elements.ElementInterface) {
name := e.GetName()
f.elements[name] = e
}
func (f *Form) Render() string {
}