Documentation
¶
Index ¶
- Constants
- func FullClean(ctx context.Context, f Form) (invalid, defaults, cleaned map[string]any)
- func HasErrors(form ErrorDefiner) bool
- func Initialize[T Form](f T, initfuncs ...func(Form)) T
- func IsValid[T any](ctx context.Context, f T) bool
- func OnFinalize(funcs ...func(Form)) func(Form)
- func OnInvalid(funcs ...func(Form)) func(Form)
- func OnValid(funcs ...func(Form)) func(Form)
- func ValueFromDataDict[T any](ctx context.Context, form FormFieldDefiner, name string, ...) (T, bool, []error)
- func WithData[T WithDataDefiner](data url.Values, files map[string][]filesystem.FileHeader, r *http.Request) func(T)
- func WithFields(fields ...Field) func(Form)
- func WithInitial(initial map[string]interface{}) func(Form)
- func WithPrefix(prefix string) func(Form)
- func WithRequestData(method string, r *http.Request) func(Form)
- type BaseBoundForm
- func (f *BaseBoundForm) AsP() template.HTML
- func (f *BaseBoundForm) AsTable() template.HTML
- func (f *BaseBoundForm) AsUL() template.HTML
- func (f *BaseBoundForm) ErrorList() []error
- func (f *BaseBoundForm) Errors() *orderedmap.OrderedMap[string, []error]
- func (f *BaseBoundForm) FieldMap() map[string]BoundField
- func (f *BaseBoundForm) Fields() []BoundField
- func (f *BaseBoundForm) Media() media.Media
- func (f *BaseBoundForm) UnpackErrors() []FieldError
- type BaseForm
- func (f *BaseForm) AddError(name string, errorList ...error)
- func (f *BaseForm) AddField(name string, field Field)
- func (f *BaseForm) AddFormError(errorList ...error)
- func (f *BaseForm) AddWidget(name string, widget Widget)
- func (f *BaseForm) BindCleanedData(invalid, defaults, cleaned map[string]interface{})
- func (f *BaseForm) BoundErrors() *orderedmap.OrderedMap[string, []error]
- func (f *BaseForm) BoundFields() *orderedmap.OrderedMap[string, BoundField]
- func (f *BaseForm) BoundForm() BoundForm
- func (f *BaseForm) CallbackOnFinalize() []func(Form)
- func (f *BaseForm) CallbackOnInvalid() []func(Form)
- func (f *BaseForm) CallbackOnValid() []func(Form)
- func (f *BaseForm) CleanedData() map[string]interface{}
- func (f *BaseForm) CleanedDataUnsafe() map[string]interface{}
- func (f *BaseForm) Context() context.Context
- func (f *BaseForm) Data() (url.Values, map[string][]filesystem.FileHeader)
- func (f *BaseForm) DeleteField(name string) bool
- func (f *BaseForm) EditContext(key string, context ctx.Context)
- func (f *BaseForm) ErrorList() []error
- func (f *BaseForm) Field(name string) (Field, bool)
- func (f *BaseForm) FieldMap() *orderedmap.OrderedMap[string, Field]
- func (f *BaseForm) FieldOrder() []string
- func (f *BaseForm) Fields() []Field
- func (f *BaseForm) FormValue(name string) interface{}
- func (f *BaseForm) HasChanged() bool
- func (f *BaseForm) InitialData() map[string]interface{}
- func (f *BaseForm) Media() media.Media
- func (f *BaseForm) OnFinalize(funcs ...func(Form))
- func (f *BaseForm) OnInvalid(funcs ...func(Form))
- func (f *BaseForm) OnValid(funcs ...func(Form))
- func (f *BaseForm) Ordering(order []string)
- func (f *BaseForm) Prefix() string
- func (f *BaseForm) PrefixName(name string) string
- func (f *BaseForm) Renderer() FormRenderer
- func (f *BaseForm) Reset()
- func (f *BaseForm) Save() (map[string]interface{}, error)
- func (f *BaseForm) SetInitial(initial map[string]interface{})
- func (f *BaseForm) SetPrefix(prefix string)
- func (f *BaseForm) SetRenderer(renderer FormRenderer)
- func (f *BaseForm) SetValidators(validators ...func(Form, map[string]interface{}) []error)
- func (f *BaseForm) Validators() []func(f Form, cleanedData map[string]interface{}) []error
- func (f *BaseForm) WasCleaned() bool
- func (f *BaseForm) Widget(name string) (Widget, bool)
- func (f *BaseForm) Widgets() []Widget
- func (f *BaseForm) WithContext(ctx context.Context)
- func (f *BaseForm) WithData(data url.Values, files map[string][]filesystem.FileHeader, r *http.Request)
- type BinderWidget
- type BoundField
- type BoundForm
- type BoundFormField
- func (b *BoundFormField) Attrs() map[string]string
- func (b *BoundFormField) Context() context.Context
- func (b *BoundFormField) Errors() []error
- func (b *BoundFormField) Field() template.HTML
- func (b *BoundFormField) HTML() template.HTML
- func (b *BoundFormField) HelpText() template.HTML
- func (b *BoundFormField) Hidden() bool
- func (b *BoundFormField) ID() string
- func (b *BoundFormField) Input() Field
- func (b *BoundFormField) Label() template.HTML
- func (b *BoundFormField) Name() string
- func (b *BoundFormField) Value() interface{}
- func (b *BoundFormField) Widget() Widget
- type Cleaner
- type ErrorAdder
- type ErrorDefiner
- type ErrorUnpacker
- type Field
- type FieldError
- type Form
- type FormBinder
- type FormFieldDefiner
- type FormRenderer
- type FormTemplateFSHook
- type FormTemplateStaticHook
- type FormValueConverter
- type FormValueGetter
- type FormValueOmitter
- type FormValuer
- type FormWrapper
- type FullCleanMixin
- type IsValidDefiner
- type Option
- type PrevalidatorMixin
- type SaveableForm
- type Validator
- type ValidatorMixin
- type Widget
- type WithDataDefiner
Constants ¶
View Source
const ( FormTemplateFSHookName = "forms.TemplateFSHook" FormTemplateStaticHookName = "forms.TemplateStaticHook" )
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func OnFinalize ¶
func ValueFromDataDict ¶ added in v1.7.2
func WithData ¶
func WithData[T WithDataDefiner](data url.Values, files map[string][]filesystem.FileHeader, r *http.Request) func(T)
func WithFields ¶
func WithInitial ¶
func WithPrefix ¶
Types ¶
type BaseBoundForm ¶ added in v1.7.2
type BaseBoundForm struct {
Form FormBinder
BoundFields []BoundField
BoundFieldMap map[string]BoundField
ErrorMap *orderedmap.OrderedMap[string, []error]
ListErrors []error
// contains filtered or unexported fields
}
func (*BaseBoundForm) AsP ¶ added in v1.7.2
func (f *BaseBoundForm) AsP() template.HTML
func (*BaseBoundForm) AsTable ¶ added in v1.7.2
func (f *BaseBoundForm) AsTable() template.HTML
func (*BaseBoundForm) AsUL ¶ added in v1.7.2
func (f *BaseBoundForm) AsUL() template.HTML
func (*BaseBoundForm) ErrorList ¶ added in v1.7.2
func (f *BaseBoundForm) ErrorList() []error
func (*BaseBoundForm) Errors ¶ added in v1.7.2
func (f *BaseBoundForm) Errors() *orderedmap.OrderedMap[string, []error]
func (*BaseBoundForm) FieldMap ¶ added in v1.7.2
func (f *BaseBoundForm) FieldMap() map[string]BoundField
func (*BaseBoundForm) Fields ¶ added in v1.7.2
func (f *BaseBoundForm) Fields() []BoundField
func (*BaseBoundForm) Media ¶ added in v1.7.2
func (f *BaseBoundForm) Media() media.Media
func (*BaseBoundForm) UnpackErrors ¶ added in v1.7.2
func (f *BaseBoundForm) UnpackErrors() []FieldError
type BaseForm ¶
type BaseForm struct {
FormPrefix string
FormFields *orderedmap.OrderedMap[string, Field]
FormWidgets *orderedmap.OrderedMap[string, Widget]
Errors *orderedmap.OrderedMap[string, []error]
ErrorList_ []error
Raw url.Values
Initial map[string]interface{}
InvalidDefaults map[string]interface{}
Files map[string][]filesystem.FileHeader
Cleaned map[string]interface{}
Defaults map[string]interface{}
FormContext context.Context
FormRenderer FormRenderer
FormValidators []func(Form, map[string]interface{}) []error
OnValidFuncs []func(Form)
OnInvalidFuncs []func(Form)
OnFinalizeFuncs []func(Form)
// contains filtered or unexported fields
}
func (*BaseForm) AddFormError ¶
func (*BaseForm) BindCleanedData ¶ added in v1.7.2
func (*BaseForm) BoundErrors ¶
func (f *BaseForm) BoundErrors() *orderedmap.OrderedMap[string, []error]
func (*BaseForm) BoundFields ¶
func (f *BaseForm) BoundFields() *orderedmap.OrderedMap[string, BoundField]
func (*BaseForm) CallbackOnFinalize ¶ added in v1.7.2
func (*BaseForm) CallbackOnInvalid ¶ added in v1.7.2
func (*BaseForm) CallbackOnValid ¶ added in v1.7.2
func (*BaseForm) CleanedData ¶
func (*BaseForm) CleanedDataUnsafe ¶ added in v1.7.2
func (*BaseForm) Data ¶ added in v1.7.2
func (f *BaseForm) Data() (url.Values, map[string][]filesystem.FileHeader)
func (*BaseForm) DeleteField ¶
func (*BaseForm) FieldMap ¶ added in v1.7.2
func (f *BaseForm) FieldMap() *orderedmap.OrderedMap[string, Field]
func (*BaseForm) FieldOrder ¶
func (*BaseForm) HasChanged ¶
func (*BaseForm) InitialData ¶
func (*BaseForm) OnFinalize ¶
func (*BaseForm) PrefixName ¶ added in v1.7.2
func (*BaseForm) Renderer ¶ added in v1.7.2
func (f *BaseForm) Renderer() FormRenderer
func (*BaseForm) SetInitial ¶
func (*BaseForm) SetRenderer ¶ added in v1.7.2
func (f *BaseForm) SetRenderer(renderer FormRenderer)
func (*BaseForm) SetValidators ¶
func (*BaseForm) Validators ¶
func (*BaseForm) WasCleaned ¶ added in v1.7.2
func (*BaseForm) WithContext ¶ added in v1.7.2
func (*BaseForm) WithData ¶
func (f *BaseForm) WithData(data url.Values, files map[string][]filesystem.FileHeader, r *http.Request)
type BinderWidget ¶ added in v1.7.2
type BinderWidget = forms.BinderWidget
type BoundField ¶
type BoundField = forms.BoundField
func NewBoundFormField ¶
func NewBoundFormField(ctx context.Context, renderer FormRenderer, w Widget, f Field, name string, value interface{}, errors []error, tryWidgetBound bool) BoundField
type BoundForm ¶
func NewBoundForm ¶ added in v1.7.2
func NewBoundForm(ctx context.Context, f FormBinder, renderer FormRenderer) BoundForm
type BoundFormField ¶
type BoundFormField struct {
FormWidget Widget
FormField Field
FormName string
FormID string
FormAttrs map[string]string
FormValue interface{}
FormErrors []error
FormContext context.Context
CachedHTML template.HTML
Renderer FormRenderer
}
func (*BoundFormField) Attrs ¶
func (b *BoundFormField) Attrs() map[string]string
func (*BoundFormField) Context ¶ added in v1.7.2
func (b *BoundFormField) Context() context.Context
func (*BoundFormField) Errors ¶
func (b *BoundFormField) Errors() []error
func (*BoundFormField) Field ¶
func (b *BoundFormField) Field() template.HTML
func (*BoundFormField) HTML ¶
func (b *BoundFormField) HTML() template.HTML
func (*BoundFormField) HelpText ¶
func (b *BoundFormField) HelpText() template.HTML
func (*BoundFormField) Hidden ¶ added in v1.7.2
func (b *BoundFormField) Hidden() bool
func (*BoundFormField) ID ¶
func (b *BoundFormField) ID() string
func (*BoundFormField) Input ¶
func (b *BoundFormField) Input() Field
func (*BoundFormField) Label ¶
func (b *BoundFormField) Label() template.HTML
func (*BoundFormField) Name ¶
func (b *BoundFormField) Name() string
func (*BoundFormField) Value ¶
func (b *BoundFormField) Value() interface{}
func (*BoundFormField) Widget ¶
func (b *BoundFormField) Widget() Widget
type ErrorAdder ¶
type ErrorAdder = forms.ErrorAdder
type ErrorDefiner ¶ added in v1.7.2
type ErrorDefiner = forms.ErrorDefiner
type ErrorUnpacker ¶ added in v1.7.2
type ErrorUnpacker interface {
UnpackErrors(boundForm BoundForm, boundErrors *orderedmap.OrderedMap[string, []error]) []FieldError
}
type FieldError ¶
type FieldError = forms.FieldError
func UnpackErrors ¶ added in v1.7.2
func UnpackErrors[T interface{ Label(context.Context) string }](bf BoundForm, f FormBinder, errorMap *orderedmap.OrderedMap[string, []error], getLabel func(string) (T, bool)) []FieldError
type FormBinder ¶ added in v1.7.2
type FormBinder interface {
FieldOrder() []string
Context() context.Context
BoundFields() *orderedmap.OrderedMap[string, BoundField]
ErrorDefiner
}
type FormFieldDefiner ¶ added in v1.7.2
type FormFieldDefiner = forms.FormFieldDefiner
type FormRenderer ¶
type FormRenderer = forms.FormRenderer
type FormTemplateFSHook ¶ added in v1.7.2
type FormValueConverter ¶ added in v1.7.2
type FormValueConverter = forms.FormValueConverter
type FormValueGetter ¶ added in v1.7.2
type FormValueGetter = forms.FormValueGetter
type FormValueOmitter ¶ added in v1.7.2
type FormValueOmitter = forms.FormValueOmitter
type FormValuer ¶ added in v1.7.2
type FormValuer = forms.FormValuer
type FormWrapper ¶ added in v1.7.2
type FormWrapper[T any] = forms.FormWrapper[T]
type FullCleanMixin ¶ added in v1.7.2
type FullCleanMixin = forms.FullCleanMixin
type IsValidDefiner ¶ added in v1.7.2
type IsValidDefiner = forms.IsValidDefiner
type PrevalidatorMixin ¶ added in v1.7.2
type PrevalidatorMixin = forms.PrevalidatorMixin
type SaveableForm ¶ added in v1.6.8
type ValidatorMixin ¶ added in v1.7.2
type ValidatorMixin = forms.ValidatorMixin
type WithDataDefiner ¶ added in v1.7.2
type WithDataDefiner = forms.WithDataDefiner
Click to show internal directories.
Click to hide internal directories.