Change HTMLInputType to use reflect Kind

master
David Vogel 11 months ago
parent 66b229c929
commit 4fa06b747c

@ -73,16 +73,29 @@ func (f ValueBindAny) SetStringValue(value string) error {
}
func (f ValueBindAny) HTMLInputType() string {
switch f.Value.(type) {
switch v := f.Value.(type) {
case HTMLInputTyper: // Support nested values.
return v.HTMLInputType()
case *time.Time:
return "datetime-local"
case *bool:
}
v := reflect.ValueOf(f.Value)
switch v.Kind() {
case reflect.Pointer, reflect.Interface:
if v.IsNil() {
return "text"
}
return ValueBindAny{Value: v.Elem().Interface()}.HTMLInputType()
case reflect.Bool:
return "text" // We will render the boolean as text, as this is an input field, not a checkbox.
case *string:
case reflect.String:
return "text"
case *int, *int8, *int16, *int32, *int64, *uint, *uint8, *uint16, *uint32, *uint64:
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return "number"
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return "number"
case *float32, *float64:
case reflect.Float32, reflect.Float64:
return "number"
}

Loading…
Cancel
Save