MCPcopy Create free account
hub / github.com/pydio/cells / StringDefault

Method StringDefault

common/forms/field.go:42–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42func (b *FormField) StringDefault() string {
43 defaultValue := ""
44 if b.Default != nil {
45 switch b.Type {
46 case ParamHidden, ParamString, ParamTextarea, ParamSelect, ParamAutoComplete, ParamAutoCompleteTree:
47 if s, ok := b.Default.(string); ok {
48 defaultValue = s
49 } else {
50 fmt.Println("[WARNING] Wrong Default Format, expected string, got", b.Default)
51 }
52 case ParamBool:
53 defaultValue = "false"
54 if bo, ok := b.Default.(bool); ok {
55 if bo {
56 defaultValue = "true"
57 }
58 } else {
59 fmt.Println("[WARNING] Wrong Default Format, expected bool, got", b.Default, " for field ", b.Name, b.Label)
60 }
61 case ParamInteger, ParamIntegerBytes:
62 if in, ok := b.Default.(int); ok {
63 defaultValue = fmt.Sprintf("%v", in)
64 } else {
65 fmt.Println("[WARNING] Wrong Default Format, expected integer, got", b.Default)
66 }
67 }
68 }
69 return defaultValue
70}
71
72func (b *FormField) Serialize(T i18n.TranslateFunc) (params []*SerialFormParam) {
73

Callers 2

SerializeMethod · 0.95
flattenGroupMethod · 0.80

Calls 1

PrintlnMethod · 0.80

Tested by

no test coverage detected