formbuilder

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJSONConfigFileNameInvalid = errors.New("*.form.json name invalid")
)

Functions

func AddChoiceByKV

func AddChoiceByKV(field fields.FieldInterface, kvData *echo.KVData, checkedKeys ...string) fields.FieldInterface

func ClearCache

func ClearCache()

func DelCachedConfig

func DelCachedConfig(file string) bool

func SetChoiceByKV

func SetChoiceByKV(field fields.FieldInterface, kvData *echo.KVData, checkedKeys ...string) fields.FieldInterface

Types

type FormBuilder

type FormBuilder struct {
	*forms.Forms
	// contains filtered or unexported fields
}

FormBuilder HTML表单构建器

func New

func New(ctx echo.Context, model interface{}, options ...Option) *FormBuilder

func (*FormBuilder) DefaultValue

func (f *FormBuilder) DefaultValue(fieldName string) string

DefaultValue 查询某个结构体字段在数据库中对应的默认值

func (*FormBuilder) DefaultValues

func (f *FormBuilder) DefaultValues() map[string]string

DefaultValues 获取model结构体各个字段在数据库中的默认值

func (*FormBuilder) Error

func (f *FormBuilder) Error() error

Error 返回错误值

func (*FormBuilder) Exit

func (f *FormBuilder) Exit(exit ...bool) *FormBuilder

Exit 设置退出标记

func (*FormBuilder) Exited

func (f *FormBuilder) Exited() bool

Exited 是否需要退出后续处理。此时一般有err值,用于记录错误原因

func (*FormBuilder) Generate

func (f *FormBuilder) Generate() *FormBuilder

Generate 生成表单参数

func (*FormBuilder) HasError

func (f *FormBuilder) HasError() bool

HasError 是否有错误

func (*FormBuilder) Off

func (f *FormBuilder) Off(methods ...string) *FormBuilder

Off 撤销事件注册

func (*FormBuilder) OffAll

func (f *FormBuilder) OffAll() *FormBuilder

Off 撤销所有事件注册

func (*FormBuilder) On

func (f *FormBuilder) On(method string, funcs ...MethodHook) *FormBuilder

On 注册事件

func (*FormBuilder) OnConnect

func (f *FormBuilder) OnConnect(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnDelete

func (f *FormBuilder) OnDelete(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnGet

func (f *FormBuilder) OnGet(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnGlobal

func (f *FormBuilder) OnGlobal(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnHead

func (f *FormBuilder) OnHead(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnOptions

func (f *FormBuilder) OnOptions(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnPatch

func (f *FormBuilder) OnPatch(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnPost

func (f *FormBuilder) OnPost(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnPut

func (f *FormBuilder) OnPut(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) OnTrace

func (f *FormBuilder) OnTrace(funcs ...MethodHook) *FormBuilder

func (*FormBuilder) ParseConfigFile

func (f *FormBuilder) ParseConfigFile() error

ParseConfigFile 解析配置文件 xxx.form.json

func (*FormBuilder) RecvSubmission

func (f *FormBuilder) RecvSubmission() error

RecvSubmission 接收客户端的提交

func (*FormBuilder) SetError

func (f *FormBuilder) SetError(err error) *FormBuilder

SetError 记录错误

func (*FormBuilder) Snippet

func (f *FormBuilder) Snippet() *FormBuilder

Snippet 表单片段

type MethodHook

type MethodHook func() error

func BindModel

func BindModel(ctx echo.Context, form *FormBuilder) MethodHook

func ValidModel

func ValidModel(ctx echo.Context, form *FormBuilder) MethodHook

type MethodHooks

type MethodHooks map[string][]MethodHook

func (MethodHooks) Fire

func (hooks MethodHooks) Fire(method string) error

func (MethodHooks) Off

func (hooks MethodHooks) Off(methods ...string)

func (MethodHooks) OffAll

func (hooks MethodHooks) OffAll()

func (MethodHooks) On

func (hooks MethodHooks) On(method string, funcs ...MethodHook)

type Option

type Option func(echo.Context, *FormBuilder)

func ConfigFile

func ConfigFile(jsonFile string, silent ...bool) Option

ConfigFile 指定要解析的配置文件。如果silent=true则仅仅设置配置文件而不解析

func DBI

func DBI(dbi *factory.DBI) Option

DBI 指定模型数据表所属DBI(数据库信息)

func FormFilter

func FormFilter(filters ...formfilter.Options) Option

FormFilter 设置表单过滤

func IgnoreFields

func IgnoreFields(ignoreFields ...string) Option

IgnoreFields 疏略某些字段的验证

func RenderBefore

func RenderBefore(fn func()) Option

RenderBefore 设置渲染表单前的钩子函数

func Theme

func Theme(theme string) Option

Theme 设置forms模板风格

func ValidFields

func ValidFields(validFields ...string) Option

ValidFields 指定仅仅验证某些字段

Jump to

Keyboard shortcuts

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