Documentation
¶
Index ¶
- Constants
- type BaseFormSet
- func (b *BaseFormSet[FORM]) AddFormError(errors ...error)
- func (b *BaseFormSet[FORM]) AddValidator(validator ...func(FORM, map[string]any) []error)
- func (b *BaseFormSet[FORM]) BoundErrors() *orderedmap.OrderedMap[string, []error]
- func (b *BaseFormSet[FORM]) BoundErrorsList() []*orderedmap.OrderedMap[string, []error]
- func (fs *BaseFormSet[FORM]) CheckIsValid(ctx context.Context, formObj any) (isValid bool)
- func (b *BaseFormSet[FORM]) CleanedData() map[string]any
- func (b *BaseFormSet[FORM]) CleanedDataList() []map[string]any
- func (fs *BaseFormSet[FORM]) Context() context.Context
- func (b *BaseFormSet[FORM]) Data() (url.Values, map[string][]filesystem.FileHeader)
- func (b *BaseFormSet[FORM]) DeletedForms() []FORM
- func (b *BaseFormSet[FORM]) ErrorList() []error
- func (b *BaseFormSet[FORM]) ErrorLists() [][]error
- func (b *BaseFormSet[FORM]) Field(name string) (fields.Field, bool)
- func (b *BaseFormSet[FORM]) ForEach(fn func(form FORM, index int) error) error
- func (b *BaseFormSet[FORM]) Form(i int) (form FORM, ok bool)
- func (b *BaseFormSet[FORM]) Forms() ([]FORM, error)
- func (b *BaseFormSet[FORM]) HasChanged() bool
- func (b *BaseFormSet[FORM]) Initial(ctx context.Context, totalForms int) (baseDefaults map[string]interface{}, defaultsList []map[string]interface{})
- func (b *BaseFormSet[FORM]) InitialData() map[string]interface{}
- func (b *BaseFormSet[FORM]) Load()
- func (b *BaseFormSet[FORM]) ManagementForm() *ManagementForm
- func (b *BaseFormSet[FORM]) Media() media.Media
- func (b *BaseFormSet[FORM]) NewForm(ctx context.Context) FORM
- func (b *BaseFormSet[FORM]) Prefix() string
- func (b *BaseFormSet[FORM]) PrefixForm(fieldName any) string
- func (b *BaseFormSet[FORM]) PrefixName(fieldName string) string
- func (b *BaseFormSet[FORM]) Save() ([]any, error)
- func (b *BaseFormSet[FORM]) SetDeletedForms(forms []FORM)
- func (b *BaseFormSet[FORM]) SetForms(forms []FORM)
- func (b *BaseFormSet[FORM]) SetPrefix(prefix string)
- func (b *BaseFormSet[FORM]) Widget(name string) (widgets.Widget, bool)
- func (fs *BaseFormSet[FORM]) WithContext(ctx context.Context)
- func (b *BaseFormSet[FORM]) WithData(data url.Values, files map[string][]filesystem.FileHeader, r *http.Request)
- type BaseFormSetForm
- type CleanedDataDefiner
- type FormsetOptions
- type ListFormSet
- type ManagementForm
Constants ¶
View Source
const ( TOTAL_FORM_COUNT = "TOTAL_FORMS" INITIAL_FORM_COUNT = "INITIAL_FORMS" MIN_NUM_FORM_COUNT = "MIN_NUM_FORMS" MAX_NUM_FORM_COUNT = "MAX_NUM_FORMS" ORDERING_FIELD_NAME = "__ORDER__" DELETION_FIELD_NAME = "__DELETE__" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseFormSet ¶
type BaseFormSet[FORM BaseFormSetForm] struct { FormList []FORM DeletedFormsList []FORM // contains filtered or unexported fields }
func NewBaseFormSet ¶
func NewBaseFormSet[FORM BaseFormSetForm](ctx context.Context, opts FormsetOptions[FORM]) *BaseFormSet[FORM]
func (*BaseFormSet[FORM]) AddFormError ¶
func (b *BaseFormSet[FORM]) AddFormError(errors ...error)
func (*BaseFormSet[FORM]) AddValidator ¶
func (b *BaseFormSet[FORM]) AddValidator(validator ...func(FORM, map[string]any) []error)
func (*BaseFormSet[FORM]) BoundErrors ¶
func (b *BaseFormSet[FORM]) BoundErrors() *orderedmap.OrderedMap[string, []error]
func (*BaseFormSet[FORM]) BoundErrorsList ¶
func (b *BaseFormSet[FORM]) BoundErrorsList() []*orderedmap.OrderedMap[string, []error]
func (*BaseFormSet[FORM]) CheckIsValid ¶
func (fs *BaseFormSet[FORM]) CheckIsValid(ctx context.Context, formObj any) (isValid bool)
func (*BaseFormSet[FORM]) CleanedData ¶
func (b *BaseFormSet[FORM]) CleanedData() map[string]any
func (*BaseFormSet[FORM]) CleanedDataList ¶
func (b *BaseFormSet[FORM]) CleanedDataList() []map[string]any
func (*BaseFormSet[FORM]) Context ¶
func (fs *BaseFormSet[FORM]) Context() context.Context
func (*BaseFormSet[FORM]) Data ¶
func (b *BaseFormSet[FORM]) Data() (url.Values, map[string][]filesystem.FileHeader)
func (*BaseFormSet[FORM]) DeletedForms ¶
func (b *BaseFormSet[FORM]) DeletedForms() []FORM
func (*BaseFormSet[FORM]) ErrorList ¶
func (b *BaseFormSet[FORM]) ErrorList() []error
func (*BaseFormSet[FORM]) ErrorLists ¶
func (b *BaseFormSet[FORM]) ErrorLists() [][]error
func (*BaseFormSet[FORM]) Field ¶
func (b *BaseFormSet[FORM]) Field(name string) (fields.Field, bool)
func (*BaseFormSet[FORM]) ForEach ¶
func (b *BaseFormSet[FORM]) ForEach(fn func(form FORM, index int) error) error
func (*BaseFormSet[FORM]) Form ¶
func (b *BaseFormSet[FORM]) Form(i int) (form FORM, ok bool)
func (*BaseFormSet[FORM]) Forms ¶
func (b *BaseFormSet[FORM]) Forms() ([]FORM, error)
func (*BaseFormSet[FORM]) HasChanged ¶
func (b *BaseFormSet[FORM]) HasChanged() bool
func (*BaseFormSet[FORM]) InitialData ¶
func (b *BaseFormSet[FORM]) InitialData() map[string]interface{}
func (*BaseFormSet[FORM]) Load ¶
func (b *BaseFormSet[FORM]) Load()
func (*BaseFormSet[FORM]) ManagementForm ¶
func (b *BaseFormSet[FORM]) ManagementForm() *ManagementForm
func (*BaseFormSet[FORM]) Media ¶
func (b *BaseFormSet[FORM]) Media() media.Media
func (*BaseFormSet[FORM]) NewForm ¶
func (b *BaseFormSet[FORM]) NewForm(ctx context.Context) FORM
func (*BaseFormSet[FORM]) Prefix ¶
func (b *BaseFormSet[FORM]) Prefix() string
func (*BaseFormSet[FORM]) PrefixForm ¶
func (b *BaseFormSet[FORM]) PrefixForm(fieldName any) string
func (*BaseFormSet[FORM]) PrefixName ¶
func (b *BaseFormSet[FORM]) PrefixName(fieldName string) string
func (*BaseFormSet[FORM]) Save ¶
func (b *BaseFormSet[FORM]) Save() ([]any, error)
func (*BaseFormSet[FORM]) SetDeletedForms ¶
func (b *BaseFormSet[FORM]) SetDeletedForms(forms []FORM)
func (*BaseFormSet[FORM]) SetForms ¶
func (b *BaseFormSet[FORM]) SetForms(forms []FORM)
func (*BaseFormSet[FORM]) SetPrefix ¶
func (b *BaseFormSet[FORM]) SetPrefix(prefix string)
func (*BaseFormSet[FORM]) Widget ¶
func (b *BaseFormSet[FORM]) Widget(name string) (widgets.Widget, bool)
func (*BaseFormSet[FORM]) WithContext ¶
func (fs *BaseFormSet[FORM]) WithContext(ctx context.Context)
func (*BaseFormSet[FORM]) WithData ¶
func (b *BaseFormSet[FORM]) WithData(data url.Values, files map[string][]filesystem.FileHeader, r *http.Request)
type BaseFormSetForm ¶
type BaseFormSetForm interface {
forms.ErrorDefiner
forms.WithDataDefiner
AddFormError(errorList ...error)
SetPrefix(prefix string)
Prefix() string
Field(name string) (fields.Field, bool)
Widget(name string) (widgets.Widget, bool)
ErrorList() []error
BoundErrors() *orderedmap.OrderedMap[string, []error]
InitialData() map[string]interface{}
WithContext(ctx context.Context)
CleanedData() map[string]any
PrefixName(fieldName string) string
HasChanged() bool
}
type CleanedDataDefiner ¶
type CleanedDataDefiner interface {
CleanedData() map[string]interface{}
}
type FormsetOptions ¶
type FormsetOptions[FORM BaseFormSetForm] struct { NewForm func(c context.Context) FORM BeforeCheckValid func(ctx context.Context, formObj any) error MinNum int Extra int MaxNum int CanOrder bool CanDelete bool CanAdd bool SkipPrefix bool HideDelete bool DefaultForms func(ctx context.Context, max, min int) ([]FORM, error) DeleteForms func(ctx context.Context, forms []FORM) error GetDefaults func(ctx context.Context, totalForms int) []map[string]interface{} BaseDefaults func(ctx context.Context) map[string]interface{} }
type ListFormSet ¶
type ListFormSet[T BaseFormSetForm] interface { forms.WithDataDefiner Load() WithContext(ctx context.Context) Context() context.Context AddFormError(errorList ...error) HasChanged() bool Media() media.Media Prefix() string SetPrefix(prefix string) PrefixName(fieldName string) string PrefixForm(fld any) string DeletedForms() []T ManagementForm() *ManagementForm Forms() ([]T, error) SetForms(forms []T) SetDeletedForms(forms []T) Field(name string) (fields.Field, bool) Widget(name string) (widgets.Widget, bool) NewForm(ctx context.Context) T Initial(ctx context.Context, totalForms int) (base map[string]interface{}, list []map[string]interface{}) Form(index int) (form T, ok bool) InitialData() map[string]interface{} // this should always return nil for formsets CleanedData() map[string]any // this should always return nil for formsets CleanedDataList() []map[string]any ErrorList() []error ErrorLists() [][]error BoundErrors() *orderedmap.OrderedMap[string, []error] BoundErrorsList() []*orderedmap.OrderedMap[string, []error] Save() ([]any, error) }
type ManagementForm ¶
type ManagementForm struct {
forms.Form
TotalFormsValue int
InitialForms int
MinNumForms int
MaxNumForms int
}
func NewManagementForm ¶
func NewManagementForm(ctx context.Context, opts ...func(*ManagementForm)) *ManagementForm
func (*ManagementForm) BindCleanedData ¶
func (m *ManagementForm) BindCleanedData(invalid, defaults, cleaned map[string]interface{})
Click to show internal directories.
Click to hide internal directories.