-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit.go
42 lines (35 loc) · 889 Bytes
/
submit.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
33
34
35
36
37
38
39
40
41
42
package fork
import "net/http"
type submitField struct {
Submitted bool
*named
Processor
}
func (s *submitField) New(i ...interface{}) Field {
var newfield submitField = *s
newfield.named = s.named.Copy()
newfield.Submitted = false
newfield.SetValidateable(false)
return &newfield
}
func (s *submitField) Get() *Value {
return NewValue(s.Submitted)
}
func (s *submitField) Set(r *http.Request) {
s.Filter(s.Name(), r)
s.Submitted = true
s.SetValidateable(true)
}
func submitWidget(options ...string) Widget {
return NewWidget(WithOptions(`<input type="submit" name="{{ .Name }}" value="{{ .Name }}" %s>`, options...))
}
func SubmitField(name string, v []interface{}, f []interface{}, options ...string) Field {
return &submitField{
named: newnamed(name),
Processor: NewProcessor(
submitWidget(options...),
NewValidater(v...),
NewFilterer(f...),
),
}
}