Documentation
¶
Index ¶
- type Form
- func (form *Form) AddChild(kind string) *Form
- func (form Form) AllPaths() []Form
- func (form Form) HTML(library *Library, schema *schema.Schema, value any) (string, error)
- func (form *Form) SetCSSClass(cssClass string) *Form
- func (form *Form) SetDescription(description string) *Form
- func (form *Form) SetID(id string) *Form
- func (form *Form) SetLabel(label string) *Form
- func (form *Form) SetOption(key string, value string) *Form
- func (form *Form) SetPath(path string) *Form
- func (form *Form) UnmarshalMap(data map[string]any) error
- func (form Form) Write(library *Library, schema *schema.Schema, value any, b *html.Builder) error
- type Library
- type OptionCode
- type OptionProvider
- type Renderer
- type Rule
- type UnmarshalMaper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Form ¶
type Form struct { Path string `json:"path"` // Path to the data value displayed in for this form element Kind string `json:"kind"` // The kind of form element ID string `json:"id,omitempty"` // DOM ID to use for this element. Label string `json:"label,omitempty"` // Short label to be displayed on the form element Description string `json:"description,omitempty"` // Longer description text to be displayed on the form element CSSClass string `json:"cssClass,omitempty"` // CSS Class override to apply to this widget. This should be used sparingly Options map[string]any `json:"options,omitempty"` // Additional custom properties defined by individual widgets Children []Form `json:"children,omitempty"` // Array of sub-form elements that may be displayed depending on the kind. Show Rule `json:"show"` // Rules for showing/hiding/disabling this element }
Form defines a single form element, or a nested form layout. It can be serialized to and from a database.
func MustParse ¶ added in v0.4.0
MustParse guarantees that a value has been parsed into a Form, or else it panics the application.
func (*Form) AddChild ¶ added in v0.4.0
AddChild adds a new child of the designated type to this form element. It returns a reference to the newly created child.
func (Form) AllPaths ¶ added in v0.2.1
AllPaths returns pointers to all of the valid paths in this form
func (*Form) SetCSSClass ¶ added in v0.4.0
SetCSSClass sets the CSSClass value for this form item
func (*Form) SetDescription ¶ added in v0.4.0
SetDescription sets the description value for this form item
func (*Form) SetPath ¶ added in v0.4.0
SetPath sets the path value for this form item This DOES NOT implement the path.Setter interface
func (*Form) UnmarshalMap ¶ added in v0.3.8
UnmarshalMap parses data from a generic structure (map[string]any) into a Form record.
type Library ¶
type Library struct { Provider OptionProvider Renderers map[string]Renderer }
Library stores all of the available Renderers, and can execute them on a set of data
func NewLibrary ¶ added in v0.4.0
func NewLibrary(provider OptionProvider) Library
NewLibrary returns a fully initialized Library
func (Library) Options ¶ added in v0.3.2
func (library Library) Options(form Form, element schema.Element) []OptionCode
type OptionCode ¶ added in v0.3.2
type OptionCode struct { Value string // Internal value of the Option Label string // Human-friendly label/name of the Option Description string // Optional long description of the Option Icon string // Optional icon to use when displaying the Option Group string // Optiional grouping to use when displaying the Option }
OptionCode represents a single value/label pair to be used in place of Enums for optional lists.
type OptionProvider ¶ added in v0.3.2
type OptionProvider interface {
OptionCodes(string) ([]OptionCode, error)
}
OptionProvider is an external object that can inject OptionCodes based on their URL.
type Renderer ¶
Renderer is a function signature that writes HTML for a fully populated widget into a string builder.
type Rule ¶ added in v0.6.0
func (Rule) HyperscriptRules ¶ added in v0.6.0
type UnmarshalMaper ¶ added in v0.6.4
type UnmarshalMaper interface { // UnmarshalMap returns a value in the format map[string]interface UnmarshalMap() map[string]any }
UnmarshalMaper wraps the UnmarshalMap interface