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 interface{}) (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) SetScript(script string) *Form
- func (form *Form) UnmarshalMap(data map[string]interface{}) error
- func (form Form) Write(library *Library, schema *schema.Schema, value interface{}, b *html.Builder) error
- type Library
- type Map
- type OptionCode
- type OptionProvider
- type Renderer
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 `json:"options,omitempty"` // Additional custom properties defined by individual widgets Script string `json:"script,omitempty"` // Hyperscript to be embedded at the base of each widget. Children []Form `json:"children,omitempty"` // Array of sub-form elements that may be displayed depending on the kind. }
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
func MustParse(data interface{}) Form
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]interface{}) 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
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.