-
Notifications
You must be signed in to change notification settings - Fork 0
/
select.go
87 lines (76 loc) · 2.07 KB
/
select.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package handlers
import (
"net/http"
mgc "github.com/mh-cbon/mdl-go-components"
"github.com/mh-cbon/mdl-go-components/components"
)
func SelectField(w http.ResponseWriter, r *http.Request) {
data := &viewData{
Title: "Select",
Components: make([]mgc.ViewComponentRenderer, 0),
}
var t1 *components.Select
var line *components.Slice
// -
line = components.NewSlice()
t1 = components.NewSelect()
t1.SetName("select")
t1.SetPlaceHolderOnly(true)
t1.SetLabel("select field")
t1.AddOption("", "")
t1.AddOption("value", "label")
t1.AddOption("value2", "label2")
t1.CheckOptions([]string{"value"})
line.AddComponent(t1)
data.Components = append(data.Components, line)
// -
line = components.NewSlice()
t1 = components.NewSelect()
t1.SetName("select")
t1.SetPlaceHolderOnly(true)
t1.SetError("this is an error")
t1.SetLabel("select field")
t1.AddOption("", "")
t1.AddOption("value", "label")
t1.AddOption("value2", "label2")
t1.CheckOptions([]string{"value"})
line.AddComponent(t1)
data.Components = append(data.Components, line)
// -
line = components.NewSlice()
t1 = components.NewSelect()
t1.SetName("select")
t1.SetLabel("select field")
t1.AddOption("", "")
t1.AddOption("value", "label")
t1.AddOption("value2", "label2")
t1.CheckOptions([]string{"value"})
line.AddComponent(t1)
data.Components = append(data.Components, line)
// -
line = components.NewSlice()
t1 = components.NewSelect()
t1.SetName("select")
t1.SetLabel("select field")
t1.SetError("this is an error")
t1.AddOption("", "")
t1.AddOption("value", "label")
t1.AddOption("value2", "label2")
t1.CheckOptions([]string{"value"})
line.AddComponent(t1)
data.Components = append(data.Components, line)
// -
line = components.NewSlice()
t1 = components.NewSelect()
t1.SetIcon("arrow_drop_down")
t1.SetLabel("select field")
t1.SetError("this is an error")
t1.AddOption("", "")
t1.AddOption("value", "label")
t1.AddOption("value2", "label2")
t1.CheckOptions([]string{"value"})
line.AddComponent(t1)
data.Components = append(data.Components, line)
// -
renderComponents(w, data)
}