-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfields.go
64 lines (56 loc) · 1.97 KB
/
fields.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
package form
type FieldType string
const (
FieldTypeGroup FieldType = "group"
FieldTypeCheckbox FieldType = "checkbox"
FieldTypeChecklist FieldType = "checklist"
FieldTypeInput FieldType = "input"
FieldTypeLabel FieldType = "label"
FieldTypeRadios FieldType = "radios"
FieldTypeDropdown FieldType = "dropdown"
FieldTypeDropdownMapped FieldType = "dropdownmapped"
FieldTypeSubmit FieldType = "submit"
FieldTypeTextArea FieldType = "textarea"
)
type InputFieldType string
const (
InputFieldTypeText InputFieldType = "text"
InputFieldTypePassword InputFieldType = "password"
InputFieldTypeEmail InputFieldType = "email"
InputFieldTypeTel InputFieldType = "tel"
InputFieldTypeNumber InputFieldType = "number"
InputFieldTypeNone InputFieldType = ""
)
func (i InputFieldType) String() string {
return string(i)
}
func (i InputFieldType) Enum() []any {
return []interface{}{
InputFieldTypeText,
InputFieldTypePassword,
InputFieldTypeEmail,
InputFieldTypeTel,
InputFieldTypeNumber,
}
}
type FieldValue struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
type FormField struct {
Id string `json:"id,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Name string `json:"name,omitempty"`
Value interface{} `json:"value,omitempty"`
Type FieldType `json:"type,omitempty"`
InputType InputFieldType `json:"inputType,omitempty"`
Label string `json:"label,omitempty"`
Step string `json:"step,omitempty"`
Rows string `json:"rows,omitempty"`
Cols string `json:"cols,omitempty"`
Values []FieldValue `json:"values,omitempty"`
Required bool `json:"required"`
Fields []FormField `json:"fields,omitempty"`
Legend string `json:"legend,omitempty"`
}