forms

package
v1.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FormTemplateFSHookName     = "forms.TemplateFSHook"
	FormTemplateStaticHookName = "forms.TemplateStaticHook"
)

Variables

This section is empty.

Functions

func FullClean added in v1.7.2

func FullClean(ctx context.Context, f Form) (invalid, defaults, cleaned map[string]any)

func HasErrors added in v1.7.2

func HasErrors(form ErrorDefiner) bool

func Initialize

func Initialize[T Form](f T, initfuncs ...func(Form)) T

func IsValid added in v1.7.2

func IsValid[T any](ctx context.Context, f T) bool

func OnFinalize

func OnFinalize(funcs ...func(Form)) func(Form)

func OnInvalid

func OnInvalid(funcs ...func(Form)) func(Form)

func OnValid

func OnValid(funcs ...func(Form)) func(Form)

func ValueFromDataDict added in v1.7.2

func ValueFromDataDict[T any](ctx context.Context, form FormFieldDefiner, name string, data map[string][]string, files map[string][]filesystem.FileHeader) (T, bool, []error)

func WithData

func WithData[T WithDataDefiner](data url.Values, files map[string][]filesystem.FileHeader, r *http.Request) func(T)

func WithFields

func WithFields(fields ...Field) func(Form)

func WithInitial

func WithInitial(initial map[string]interface{}) func(Form)

func WithPrefix

func WithPrefix(prefix string) func(Form)

func WithRequestData

func WithRequestData(method string, r *http.Request) func(Form)

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 NewBaseForm

func NewBaseForm(ctx context.Context, opts ...func(Form)) *BaseForm

func (*BaseForm) AddError

func (f *BaseForm) AddError(name string, errorList ...error)

func (*BaseForm) AddField

func (f *BaseForm) AddField(name string, field Field)

func (*BaseForm) AddFormError

func (f *BaseForm) AddFormError(errorList ...error)

func (*BaseForm) AddWidget

func (f *BaseForm) AddWidget(name string, widget Widget)

func (*BaseForm) BindCleanedData added in v1.7.2

func (f *BaseForm) BindCleanedData(invalid, defaults, cleaned map[string]interface{})

func (*BaseForm) BoundErrors

func (f *BaseForm) BoundErrors() *orderedmap.OrderedMap[string, []error]

func (*BaseForm) BoundFields

func (f *BaseForm) BoundFields() *orderedmap.OrderedMap[string, BoundField]

func (*BaseForm) BoundForm

func (f *BaseForm) BoundForm() BoundForm

func (*BaseForm) CallbackOnFinalize added in v1.7.2

func (f *BaseForm) CallbackOnFinalize() []func(Form)

func (*BaseForm) CallbackOnInvalid added in v1.7.2

func (f *BaseForm) CallbackOnInvalid() []func(Form)

func (*BaseForm) CallbackOnValid added in v1.7.2

func (f *BaseForm) CallbackOnValid() []func(Form)

func (*BaseForm) CleanedData

func (f *BaseForm) CleanedData() map[string]interface{}

func (*BaseForm) CleanedDataUnsafe added in v1.7.2

func (f *BaseForm) CleanedDataUnsafe() map[string]interface{}

func (*BaseForm) Context added in v1.7.2

func (f *BaseForm) Context() context.Context

func (*BaseForm) Data added in v1.7.2

func (f *BaseForm) Data() (url.Values, map[string][]filesystem.FileHeader)

func (*BaseForm) DeleteField

func (f *BaseForm) DeleteField(name string) bool

func (*BaseForm) EditContext

func (f *BaseForm) EditContext(key string, context ctx.Context)

func (*BaseForm) ErrorList

func (f *BaseForm) ErrorList() []error

func (*BaseForm) Field

func (f *BaseForm) Field(name string) (Field, bool)

func (*BaseForm) FieldMap added in v1.7.2

func (f *BaseForm) FieldMap() *orderedmap.OrderedMap[string, Field]

func (*BaseForm) FieldOrder

func (f *BaseForm) FieldOrder() []string

func (*BaseForm) Fields

func (f *BaseForm) Fields() []Field

func (*BaseForm) FormValue

func (f *BaseForm) FormValue(name string) interface{}

func (*BaseForm) HasChanged

func (f *BaseForm) HasChanged() bool

func (*BaseForm) InitialData

func (f *BaseForm) InitialData() map[string]interface{}

func (*BaseForm) Media

func (f *BaseForm) Media() media.Media

func (*BaseForm) OnFinalize

func (f *BaseForm) OnFinalize(funcs ...func(Form))

func (*BaseForm) OnInvalid

func (f *BaseForm) OnInvalid(funcs ...func(Form))

func (*BaseForm) OnValid

func (f *BaseForm) OnValid(funcs ...func(Form))

func (*BaseForm) Ordering

func (f *BaseForm) Ordering(order []string)

func (*BaseForm) Prefix

func (f *BaseForm) Prefix() string

func (*BaseForm) PrefixName added in v1.7.2

func (f *BaseForm) PrefixName(name string) string

func (*BaseForm) Renderer added in v1.7.2

func (f *BaseForm) Renderer() FormRenderer

func (*BaseForm) Reset

func (f *BaseForm) Reset()

func (*BaseForm) Save added in v1.6.8

func (f *BaseForm) Save() (map[string]interface{}, error)

func (*BaseForm) SetInitial

func (f *BaseForm) SetInitial(initial map[string]interface{})

func (*BaseForm) SetPrefix

func (f *BaseForm) SetPrefix(prefix string)

func (*BaseForm) SetRenderer added in v1.7.2

func (f *BaseForm) SetRenderer(renderer FormRenderer)

func (*BaseForm) SetValidators

func (f *BaseForm) SetValidators(validators ...func(Form, map[string]interface{}) []error)

func (*BaseForm) Validators

func (f *BaseForm) Validators() []func(f Form, cleanedData map[string]interface{}) []error

func (*BaseForm) WasCleaned added in v1.7.2

func (f *BaseForm) WasCleaned() bool

func (*BaseForm) Widget

func (f *BaseForm) Widget(name string) (Widget, bool)

func (*BaseForm) Widgets

func (f *BaseForm) Widgets() []Widget

func (*BaseForm) WithContext added in v1.7.2

func (f *BaseForm) WithContext(ctx context.Context)

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

type BoundForm = forms.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 Cleaner

type Cleaner = forms.Cleaner

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 Field added in v1.7.2

type Field = forms.Field

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 Form

type Form = forms.Form

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 FormTemplateFSHook func(fSys fs.FS, cnf *tpl.Config) fs.FS

type FormTemplateStaticHook added in v1.7.2

type FormTemplateStaticHook func(fSys fs.FS) fs.FS

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 Option added in v1.7.2

type Option = forms.Option

type PrevalidatorMixin added in v1.7.2

type PrevalidatorMixin = forms.PrevalidatorMixin

type SaveableForm added in v1.6.8

type SaveableForm interface {
	Form
	Save() (map[string]interface{}, error)
}

type Validator

type Validator = forms.Validator

type ValidatorMixin added in v1.7.2

type ValidatorMixin = forms.ValidatorMixin

type Widget added in v1.7.2

type Widget = forms.Widget

type WithDataDefiner added in v1.7.2

type WithDataDefiner = forms.WithDataDefiner

Directories

Path Synopsis
templ: version: v0.3.1020
templ: version: v0.3.1020

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL