()
| 40 | } |
| 41 | |
| 42 | func (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 | |
| 72 | func (b *FormField) Serialize(T i18n.TranslateFunc) (params []*SerialFormParam) { |
| 73 |
no test coverage detected