form

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HiddenFieldTemplate = template.Must(template.New("").Parse(`<input type="hidden" name="{{.Name}}" value="{{.Value}}">`))

Functions

This section is empty.

Types

type Checkbox

type Checkbox struct {
	Checked  bool
	Cols     int
	Error    string
	Label    string
	Name     string
	Template string
	Value    string
	Vars     any
}

func (*Checkbox) Render

func (f *Checkbox) Render(theme string, w io.Writer) error

type Date

type Date struct {
	Cols     int
	Disabled bool
	Error    string
	Label    string
	Max      string
	Min      string
	Name     string
	Required bool
	Template string
	Tooltip  string
	Value    string
	Vars     any
}

func (*Date) Render

func (f *Date) Render(theme string, w io.Writer) error

type Errors

type Errors []string

func (Errors) Render

func (e Errors) Render() (template.HTML, error)

type Field

type Field interface {
	Render(string, io.Writer) error
}

type Form

type Form struct {
	Theme    string
	Errors   Errors
	Sections []Section
}

func New

func New() *Form

func (*Form) AddSection

func (f *Form) AddSection(fields ...Field) *Form

func (*Form) AddTemplatedSection

func (f *Form) AddTemplatedSection(template string, vars any, fields ...Field) *Form

func (*Form) WithErrors

func (f *Form) WithErrors(errors []string) *Form

func (*Form) WithTheme

func (f *Form) WithTheme(theme string) *Form

type Hidden

type Hidden struct {
	Name  string
	Value string
}

func (*Hidden) Render

func (f *Hidden) Render(theme string, w io.Writer) error

type RadioButtonGroup

type RadioButtonGroup struct {
	Cols     int
	Error    string
	Label    string
	Name     string
	Options  []SelectOption
	Required bool
	Template string
	Tooltip  string
	Value    string
	Vars     any
}

func (*RadioButtonGroup) Render

func (f *RadioButtonGroup) Render(theme string, w io.Writer) error

type Section

type Section struct {
	Fields   []Field
	Form     *Form
	Template string
	Vars     any
}

func (*Section) Render

func (s *Section) Render() (template.HTML, error)

type Select

type Select struct {
	Cols        int
	Disabled    bool
	EmptyOption bool
	Error       string
	Help        template.HTML
	Label       string
	Name        string
	Options     []SelectOption
	Required    bool
	Template    string
	Tooltip     string
	Value       string
	Vars        any
}

func (*Select) Render

func (f *Select) Render(theme string, w io.Writer) error

type SelectOption

type SelectOption struct {
	Label string
	Value string
}

type SelectRepeat

type SelectRepeat struct {
	Cols        int
	EmptyOption bool
	Error       string
	Label       string
	Name        string
	Options     []SelectOption
	Required    bool
	Template    string
	Tooltip     string
	Values      []string
	Vars        any
}

func (*SelectRepeat) Render

func (f *SelectRepeat) Render(theme string, w io.Writer) error

type Text

type Text struct {
	AutocompleteURL string
	Cols            int
	Disabled        bool
	Error           string
	ID              string
	Label           string
	Name            string
	Help            template.HTML
	Readonly        bool
	Required        bool
	Template        string
	Tooltip         string
	Value           string
	Vars            any
}

func (*Text) Render

func (f *Text) Render(theme string, w io.Writer) error

type TextArea

type TextArea struct {
	Cols     int
	Error    string
	Label    string
	Name     string
	Help     template.HTML
	Required bool
	Rows     int
	Template string
	Tooltip  string
	Value    string
	Vars     any
}

func (*TextArea) Render

func (f *TextArea) Render(theme string, w io.Writer) error

type TextRepeat

type TextRepeat struct {
	AutocompleteURL string
	Cols            int
	Disabled        bool
	Error           string
	ID              string
	Label           string
	Name            string
	Help            template.HTML
	Readonly        bool
	Required        bool
	Template        string
	Tooltip         string
	Values          []string
	Vars            any
}

func (*TextRepeat) Render

func (f *TextRepeat) Render(theme string, w io.Writer) error

Jump to

Keyboard shortcuts

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