forms

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: BSD-1-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form struct {
	CSRFToken     *request.CSRFToken
	Method, URL   string
	Fields        []*FormField
	Model         any
	UpdatedFields []string
	Disabled      bool
}

Create a new form for a model.

func NewForm

func NewForm(method, url string, rq *request.Request, db *gorm.DB, mdl any) *Form

Instantiate a new form.

func (*Form) Disable

func (f *Form) Disable()

Disable the form, and all its fields.

func (*Form) Process

func (f *Form) Process(r *request.Request, mgr *fs.Manager, db *gorm.DB) (any, bool, error)

Process and save the form if valid.

func (*Form) Render

func (f *Form) Render() template.HTML

func (*Form) Save

func (f *Form) Save(db *gorm.DB) (bool, error)

Save a form to the database. Validate if the new value is different from the old value.

type FormField

type FormField struct {
	Name, Label, Type, Value                string
	Autocomplete, Custom                    string
	ReadOnly, Checked, Disabled, NeedsAdmin bool
	Required, Multiple, Selected            bool

	Classes, LabelClasses, DivClasses []string
	Options                           []*FormField
	Model                             interface{}
	// contains filtered or unexported fields
}

Formfield struct used to render and validate the form.

func (*FormField) Disable

func (f *FormField) Disable()

Disable an individual field.

func (*FormField) Render

func (f *FormField) Render(fieldBuilder *strings.Builder)

type GetTyper added in v1.0.6

type GetTyper interface {
	GetType() string
}

Jump to

Keyboard shortcuts

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