Documentation ¶
Rendered for js/wasm
Index ¶
- Constants
- func FormDataToStruct(data map[string]string, s any) error
- func FormatIfDateTime(val any) any
- func SetValue(s any, column string, value any)
- func SetValueStrict(s any, f reflect.StructField, v reflect.Value, column string, value any)
- func TransformValue(s any, field string, val any) (any, error)
- type FORMTYPES
- type Form
- func (f *Form) AddValidator(name string, fn func(string) error)
- func (f *Form) AttrID(id string) *Form
- func (f *Form) Element() *elements.Element
- func (f *Form) OnSubmit(cb func(data map[string]string, elements []jsext.Element))
- func (f *Form) OnSubmitToStruct(strct any, fn func(strct any, elements []jsext.Element))
- func (f *Form) Render() jsext.Element
- func (f *Form) Value() jsext.Element
Constants ¶
View Source
const Delimiter = "___"
Form delimiter for nested structs
Variables ¶
This section is empty.
Functions ¶
func FormDataToStruct ¶
Parse form data to a struct.
func SetValueStrict ¶
Set a value on a struct, faster option.
Types ¶
type FORMTYPES ¶
type FORMTYPES string
Valid formtypes
const ( FORMTYP_TEXT FORMTYPES = "text" FORMTYP_CHECKBOX FORMTYPES = "checkbox" FORMTYP_NUMBER FORMTYPES = "number" FORMTYP_DATETIME FORMTYPES = "datetime-local" FORMTYP_FILE FORMTYPES = "file" FORMTYP_STRUCT FORMTYPES = "struct" // FORMTYP_LIST FORMTYPES = "select" FORMTYP_INVALID FORMTYPES = "text" )
Formtypes to use in forms
func ReflectInputType ¶
Reflect the form input type of a value
type Form ¶
Form struct
func StructToForm ¶
Render a struct into a form
func (*Form) AddValidator ¶
Add a validator to the form. The validator will be called when the form is submitted. WATCH OUT!
The form names could be transformed when you parse a struct into a form; Please use the same name as the struct field name, for embedded structs the delimiter is used:
"Field" for a normal field "Other___Field" for an embedded field
func (*Form) OnSubmitToStruct ¶
Eventlistener for when the form is submitted, data is parsed into a struct
Click to show internal directories.
Click to hide internal directories.