inferInputType decides the appropriate frontend input widget for a field based on its schema type and enum values.
(typeName string, enum []string)
| 242 | // inferInputType decides the appropriate frontend input widget for |
| 243 | // a field based on its schema type and enum values. |
| 244 | func inferInputType(typeName string, enum []string) string { |
| 245 | if len(enum) > 0 { |
| 246 | return "select" |
| 247 | } |
| 248 | switch typeName { |
| 249 | case "boolean": |
| 250 | return "select" |
| 251 | case "array", "object": |
| 252 | return "json" |
| 253 | default: |
| 254 | return "input" |
| 255 | } |
| 256 | } |