config

package
v0.0.0-...-1e2aeba Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATIC   = "static"
	Disabled = "disabled"
	Readonly = "readonly"
)

Variables

This section is empty.

Functions

func GetCols

func GetCols(labelCols int, fieldCols int) int

func GetFieldCols

func GetFieldCols(fieldCols int) int

func GetLabelCols

func GetLabelCols(labelCols int) int

Types

type Choice

type Choice struct {
	Group   string   `json:"group"`
	Option  []string `json:"option"` //["value","text"]
	Checked bool     `json:"checked"`
}

func (*Choice) Clone

func (c *Choice) Clone() *Choice

func (*Choice) Merge

func (c *Choice) Merge(source *Choice) *Choice

type Config

type Config struct {
	ID             string                 `json:"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

func (c *Config) AddAttribute(attributes ...string) *Config

func (*Config) AddButton

func (c *Config) AddButton(buttons ...string) *Config

func (*Config) AddElement

func (c *Config) AddElement(elements ...*Element) *Config

func (*Config) AddLanguage

func (c *Config) AddLanguage(languages ...*Language) *Config

func (*Config) Clone

func (c *Config) Clone() *Config

func (*Config) GetNames

func (c *Config) GetNames() []string

func (*Config) GetValue

func (c *Config) GetValue(fieldValue func(fieldName string, fieldValue string) error) error

func (*Config) HasName

func (c *Config) HasName(name string) bool

func (*Config) Merge

func (c *Config) Merge(source *Config) *Config

func (*Config) Set

func (c *Config) Set(name string, value interface{}) *Config

func (*Config) SetDefaultValue

func (c *Config) SetDefaultValue(fieldDefaultValue func(fieldName string) string)

func (*Config) SetValue

func (c *Config) SetValue(fieldValue func(fieldName string) string)

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

func (e *Element) AddAttribute(attributes ...string) *Element

func (*Element) AddChoice

func (e *Element) AddChoice(choices ...*Choice) *Element

func (*Element) AddElement

func (e *Element) AddElement(elements ...*Element) *Element

func (*Element) AddLabelClass

func (e *Element) AddLabelClass(labelClasses ...string) *Element

func (*Element) AddLanguage

func (e *Element) AddLanguage(languages ...*Language) *Element

func (*Element) Clone

func (e *Element) Clone() *Element

func (*Element) Cols

func (e *Element) Cols() int

func (*Element) HasAttr

func (e *Element) HasAttr(attrs ...string) bool

func (*Element) Merge

func (c *Element) Merge(source *Element) *Element

func (*Element) Set

func (e *Element) Set(name string, value interface{}) *Element

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

type Grouped struct {
	HasError bool
	Elements []FormElement
}

type Groups

type Groups []Grouped

func SplitGroup

func SplitGroup(elements []FormElement) Groups

type HasError

type HasError interface {
	HasError() bool
}

type Language

type Language struct {
	ID         string `json:"id"`
	Label      string `json:"label"`
	NameFormat string `json:"nameFormat"`
	// contains filtered or unexported fields
}

func NewLanguage

func NewLanguage(lang, label, namefmt string) *Language

func (*Language) AddField

func (l *Language) AddField(f ...FormElement)

func (*Language) Clone

func (l *Language) Clone() *Language

func (*Language) Field

func (l *Language) Field(name string) FormElement

func (*Language) Fields

func (l *Language) Fields() []FormElement

func (*Language) Groups

func (l *Language) Groups() Groups

func (*Language) HasName

func (l *Language) HasName(name string) bool

func (*Language) Name

func (l *Language) Name(name string) string

Jump to

Keyboard shortcuts

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