Documentation
¶
Index ¶
- Constants
- func GetCols(labelCols int, fieldCols int) int
- func GetFieldCols(fieldCols int) int
- func GetLabelCols(labelCols int) int
- type Choice
- type Config
- func (c *Config) AddAttribute(attributes ...string) *Config
- func (c *Config) AddButton(buttons ...string) *Config
- func (c *Config) AddElement(elements ...*Element) *Config
- func (c *Config) AddLanguage(languages ...*Language) *Config
- func (c *Config) Clone() *Config
- func (c *Config) GetNames() []string
- func (c *Config) GetValue(fieldValue func(fieldName string, fieldValue string) error) error
- func (c *Config) HasName(name string) bool
- func (c *Config) Merge(source *Config) *Config
- func (c *Config) Set(name string, value interface{}) *Config
- func (c *Config) SetDefaultValue(fieldDefaultValue func(fieldName string) string)
- func (c *Config) SetValue(fieldValue func(fieldName string) string)
- type Element
- func (e *Element) AddAttribute(attributes ...string) *Element
- func (e *Element) AddChoice(choices ...*Choice) *Element
- func (e *Element) AddElement(elements ...*Element) *Element
- func (e *Element) AddLabelClass(labelClasses ...string) *Element
- func (e *Element) AddLanguage(languages ...*Language) *Element
- func (e *Element) Clone() *Element
- func (e *Element) Cols() int
- func (e *Element) HasAttr(attrs ...string) bool
- func (c *Element) Merge(source *Element) *Element
- func (e *Element) Set(name string, value interface{}) *Element
- type FieldInterface
- type FormElement
- type Grouped
- type Groups
- type HasError
- type Language
- func (l *Language) AddField(f ...FormElement)
- func (l *Language) Clone() *Language
- func (l *Language) Field(name string) FormElement
- func (l *Language) Fields() []FormElement
- func (l *Language) Groups() Groups
- func (l *Language) HasName(name string) bool
- func (l *Language) Name(name string) string
- func (l *Language) Set(name string, value interface{}) *Language
Constants ¶
View Source
const ( STATIC = "static" Disabled = "disabled" Readonly = "readonly" )
Variables ¶
This section is empty.
Functions ¶
func GetFieldCols ¶ added in v1.13.4
func GetLabelCols ¶ added in v1.13.4
Types ¶
type Choice ¶
type Config ¶
type Config struct {
ID string `json:"id"` // 表单ID,用于区分不同表单
Theme string `json:"theme"` // 表单主题
Template string `json:"template"` // 表单模板
Method string `json:"method"` // 表单提交方法
Action string `json:"action"` // 表单提交地址
Attributes [][]string `json:"attributes"` // 表单属性
WithButtons bool `json:"withButtons"` // 是否显示表单按钮
Buttons []string `json:"buttons"` // 表单按钮
BtnsTemplate string `json:"btnsTemplate"` // 表单按钮模板
Elements []*Element `json:"elements"` // 表单元素
Languages []*Language `json:"languages"` // 表单多语言支持
Data map[string]interface{} `json:"data,omitempty"` // 额外数据
TrimNamePrefix string `json:"trimNamePrefix,omitempty"` // 去除字段名前缀
}
func (*Config) AddAttribute ¶ added in v1.10.0
func (*Config) AddElement ¶ added in v1.10.0
func (*Config) AddLanguage ¶ added in v1.10.0
func (*Config) SetDefaultValue ¶ added in v1.8.7
type Element ¶
type Element struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Label string `json:"label"`
LabelCols int `json:"labelCols,omitempty"`
FieldCols int `json:"fieldCols,omitempty"`
LabelClasses []string `json:"labelClasses,omitempty"`
Value string `json:"value"`
HelpText string `json:"helpText"`
Template string `json:"template"`
Valid string `json:"valid"`
Attributes [][]string `json:"attributes"`
Choices []*Choice `json:"choices"`
Elements []*Element `json:"elements"`
Format string `json:"format"`
Languages []*Language `json:"languages,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
func (*Element) AddAttribute ¶ added in v1.10.0
func (*Element) AddElement ¶ added in v1.10.0
func (*Element) AddLabelClass ¶ added in v1.13.8
func (*Element) AddLanguage ¶ added in v1.10.0
type FieldInterface ¶ added in v1.13.15
type FieldInterface interface {
Name() string
OriginalName() string
Cols() int
SetName(string)
SetLabelCols(cols int)
SetFieldCols(cols int)
Render() template.HTML
AddClass(class string) FieldInterface
RemoveClass(class string) FieldInterface
AddTag(class string) FieldInterface
RemoveTag(class string) FieldInterface
SetID(id string) FieldInterface
SetParam(key string, value interface{}) FieldInterface
DeleteParam(key string) FieldInterface
AddCSS(key, value string) FieldInterface
RemoveCSS(key string) FieldInterface
SetTheme(theme string) FieldInterface
SetLabel(label string) FieldInterface
AddLabelClass(class string) FieldInterface
RemoveLabelClass(class string) FieldInterface
SetValue(value string) FieldInterface
Disabled() FieldInterface
Enabled() FieldInterface
SetTemplate(tmpl string, theme ...string) FieldInterface
SetHelptext(text string) FieldInterface
AddError(err string) FieldInterface
MultipleChoice() FieldInterface
SingleChoice() FieldInterface
AddSelected(opt ...string) FieldInterface
SetSelected(opt ...string) FieldInterface
RemoveSelected(opt string) FieldInterface
AddChoice(key, value interface{}, checked ...bool) FieldInterface
SetChoices(choices interface{}, saveIndex ...bool) FieldInterface
SetText(text string) FieldInterface
SetData(key string, value interface{})
Data() map[string]interface{}
String() string
SetLang(lang string)
Lang() string
Clone() FormElement
Element() *Element
}
FieldInterface defines the interface an object must implement to be used in a form. Every method returns a FieldInterface object to allow methods chaining.
type FormElement ¶
type FormElement interface {
Render() template.HTML
Name() string
Cols() int
OriginalName() string
SetName(string)
String() string
SetData(key string, value interface{})
Data() map[string]interface{}
SetLang(lang string)
Lang() string
Clone() FormElement
}
FormElement interface defines a form object (usually a Field or a FieldSet) that can be rendered as a template.HTML object.
type Grouped ¶ added in v1.13.4
type Grouped struct {
HasError bool
Elements []FormElement
}
type Groups ¶ added in v1.13.4
type Groups []Grouped
func SplitGroup ¶ added in v1.13.4
func SplitGroup(elements []FormElement) Groups
type Language ¶
type Language struct {
ID string `json:"id"`
Label string `json:"label"`
NameFormat string `json:"nameFormat"`
Data map[string]interface{} `json:"data,omitempty"`
// contains filtered or unexported fields
}
func NewLanguage ¶
func (*Language) AddField ¶
func (l *Language) AddField(f ...FormElement)
func (*Language) Field ¶
func (l *Language) Field(name string) FormElement
func (*Language) Fields ¶
func (l *Language) Fields() []FormElement
Click to show internal directories.
Click to hide internal directories.