modelforms

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModelForm

type BaseModelForm[T attrs.Definer] struct {
	*forms.BaseForm
	Model          T
	Definition     attrs.Definitions
	InstanceFields []attrs.Field

	Initial      func() T
	SaveInstance func(context.Context, T) error
	ModelFields  []string
	ModelExclude []string
	// contains filtered or unexported fields
}

func NewBaseModelForm

func NewBaseModelForm[T attrs.Definer](model T, opts ...func(forms.Form)) *BaseModelForm[T]

func (*BaseModelForm[T]) Context

func (f *BaseModelForm[T]) Context() context.Context

func (*BaseModelForm[T]) Instance

func (f *BaseModelForm[T]) Instance() T

func (*BaseModelForm[T]) Load

func (f *BaseModelForm[T]) Load()

func (*BaseModelForm[T]) Reset

func (f *BaseModelForm[T]) Reset()

func (*BaseModelForm[T]) Save

func (f *BaseModelForm[T]) Save() error

func (*BaseModelForm[T]) SetExclude

func (f *BaseModelForm[T]) SetExclude(exclude ...string)

func (*BaseModelForm[T]) SetFields

func (f *BaseModelForm[T]) SetFields(fields ...string)

func (*BaseModelForm[T]) SetInstance

func (f *BaseModelForm[T]) SetInstance(model T)

func (*BaseModelForm[T]) WithContext

func (f *BaseModelForm[T]) WithContext(ctx context.Context)

type ModelForm

type ModelForm[T any] interface {
	forms.Form
	Load()
	Save() error
	WithContext(ctx context.Context)
	Context() context.Context
	SetFields(fields ...string)
	SetExclude(exclude ...string)
	Instance() T
	SetInstance(model T)
}

Jump to

Keyboard shortcuts

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